When to replace RDBMS/ORM with NoSQL/DocumentStore

我只是一个虾纸丫 提交于 2019-12-08 21:20:30

All of the examples you mentioned can be built using a document store. Whether you should use it, depends on the exact requirements.

If you're dealing with a social community that supports money transactions, you really should use an RDBMS to handle these transactions. You simply cannot afford to have inconsistent data in this area.

If your application doesn't have very stringent requirements in terms of data consistency, you can consider using a document database. It has several advantages over an RDBMS. For example, if you're using domain-driven design to build your application, you'll find that aggregate roots can be naturally stored as a single document. This will result in very little data fragmentation within entities, giving you better performance when you're sharding your data across multiple nodes.

Some drivers, including NoRM for MongoDB, support type discriminators. These allow you to persist and rehydrate multiple subclasses using very little configuration. For example, if your application supports multiple types of home addresses, the driver will take care of handling the different address subtypes. You can also add new subtypes and the driver will automatically handle these as well. See this article for a detailed example.

The above wouldn't be possible without the biggest advantage of document-oriented stores over SQL databases: schema-less data. If you're dealing with user-defined data, document databases are the way to go. For example, if you allow users to upload files and freely tag them with whatever data they want, you can easily store these tags as plain key-value pairs, or even nested key-value structures for categorized tagging.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!