文档存储的最佳用途是什么?

时间:2022-12-27 19:21:57

I have been hearing a lot about document oriented data stores like CouchDB. I understand the uses of BigTable like stores such as Cassandra. After reading this question, I was wondering what the conditions would be to merit using a document store?

我听说过很多关于像CouchDB这样的面向文档的数据存储。我理解BigTable的用途,比如Cassandra等商店。在阅读完这个问题之后,我想知道使用文档存储的条件是什么?

2 个解决方案

#1


29  

Column-family stores such as Bigtable and Cassandra have very limited querying capabilities. The application is responsible for maintaining indexes in order to query a more complex data model.

Bigtable和Cassandra等列式系列商店的查询功能非常有限。应用程序负责维护索引以查询更复杂的数据模型。

Document databases allow you to query the content, not just the key. It will also manage the indexes for you, reducing the complexity of your application.

文档数据库允许您查询内容,而不仅仅是密钥。它还将为您管理索引,从而降低应用程序的复杂性。

Domain-driven design evangelizes the use of aggregates and value objects. As Ayende points out, (complex) aggregates are very natural candidates to be stored as a single document, instead of normalizing them over multiple tables or column families. This will reduce the complexity of your persistence layer. There's also less chance that related data is scattered across multiple nodes, as all the data is contained in a single document.

领域驱动的设计传播聚合和价值对象的使用。正如Ayende指出的那样,(复杂)聚合是非常自然的候选者,可以存储为单个文档,而不是将它们标准化为多个表或列族。这将降低持久层的复杂性。相关数据分散在多个节点上的可能性也较小,因为所有数据都包含在单个文档中。

If your application needs to store polymorphic objects, document databases are also a good candidate. Of course, this could also be stored in Cassandra, but you won't have as much querying capabilities. At least not out of the box.

如果您的应用程序需要存储多态对象,那么文档数据库也是一个很好的选择。当然,这也可以存储在Cassandra中,但是你没有那么多的查询功能。至少没有开箱即用。

Think of a document database as a luxurious sports car. It doesn't need a professional driver (read: complex application) to get you from A to B, it has features such as air conditioning and comfortable seats and it will lap the high-scalability track in an acceptable time. However, if you want to set a lap record on the high-scalability track, you will need a professional driver and a highly optimized car (e.g. Cassandra), which lacks features such as air conditioning.

将文档数据库视为豪华跑车。它不需要专业的驱动程序(阅读:复杂的应用程序)让您从A到B,它具有空调和舒适座椅等功能,它将在可接受的时间内完成高可扩展性轨道。但是,如果您想在高可扩展性轨道上设置单圈记录,您将需要一个专业的驾驶员和高度优化的汽车(例如Cassandra),它缺乏空调等功能。

#2


9  

Another feature of CouchDB is that you can create those aggregations, not as documents stored manually, but as views (which are derived from the stored data, and updated automatically.)

CouchDB的另一个特性是您可以创建这些聚合,而不是手动存储的文档,而是视图(从存储的数据派生并自动更新)。

This is like power windows, heated seats, or the kicking stereo.

这就像电动车窗,加热座椅或踢脚音响。

#1


29  

Column-family stores such as Bigtable and Cassandra have very limited querying capabilities. The application is responsible for maintaining indexes in order to query a more complex data model.

Bigtable和Cassandra等列式系列商店的查询功能非常有限。应用程序负责维护索引以查询更复杂的数据模型。

Document databases allow you to query the content, not just the key. It will also manage the indexes for you, reducing the complexity of your application.

文档数据库允许您查询内容,而不仅仅是密钥。它还将为您管理索引,从而降低应用程序的复杂性。

Domain-driven design evangelizes the use of aggregates and value objects. As Ayende points out, (complex) aggregates are very natural candidates to be stored as a single document, instead of normalizing them over multiple tables or column families. This will reduce the complexity of your persistence layer. There's also less chance that related data is scattered across multiple nodes, as all the data is contained in a single document.

领域驱动的设计传播聚合和价值对象的使用。正如Ayende指出的那样,(复杂)聚合是非常自然的候选者,可以存储为单个文档,而不是将它们标准化为多个表或列族。这将降低持久层的复杂性。相关数据分散在多个节点上的可能性也较小,因为所有数据都包含在单个文档中。

If your application needs to store polymorphic objects, document databases are also a good candidate. Of course, this could also be stored in Cassandra, but you won't have as much querying capabilities. At least not out of the box.

如果您的应用程序需要存储多态对象,那么文档数据库也是一个很好的选择。当然,这也可以存储在Cassandra中,但是你没有那么多的查询功能。至少没有开箱即用。

Think of a document database as a luxurious sports car. It doesn't need a professional driver (read: complex application) to get you from A to B, it has features such as air conditioning and comfortable seats and it will lap the high-scalability track in an acceptable time. However, if you want to set a lap record on the high-scalability track, you will need a professional driver and a highly optimized car (e.g. Cassandra), which lacks features such as air conditioning.

将文档数据库视为豪华跑车。它不需要专业的驱动程序(阅读:复杂的应用程序)让您从A到B,它具有空调和舒适座椅等功能,它将在可接受的时间内完成高可扩展性轨道。但是,如果您想在高可扩展性轨道上设置单圈记录,您将需要一个专业的驾驶员和高度优化的汽车(例如Cassandra),它缺乏空调等功能。

#2


9  

Another feature of CouchDB is that you can create those aggregations, not as documents stored manually, but as views (which are derived from the stored data, and updated automatically.)

CouchDB的另一个特性是您可以创建这些聚合,而不是手动存储的文档,而是视图(从存储的数据派生并自动更新)。

This is like power windows, heated seats, or the kicking stereo.

这就像电动车窗,加热座椅或踢脚音响。