问题描述
我有一个正在考虑移植到CouchDB或MongoDB的MSSQL数据库.我在SQL db中有一个多对多关系,在外部参照表中有成千上万的行,对应于关系每一侧的表中有成千上万的行. CouchDB和/或MongoDB是否能够处理这些数据,格式化相关文档以进行性能查询的最佳方法是什么?非常感谢.
I have an MSSQL database which I am considering porting to CouchDB or MongoDB. I have a many-to-many relationship within the SQL db which has hundreds of thousands rows in the xref table, corresponding to tens of thousands of rows in the tables on each side of the relationship. Will CouchDB and/or MongoDB be able to handle this data, and what would be the best way of formatting the relevant documents for performant querying? Thanks very much.
推荐答案
对于CouchDB,我强烈建议阅读本文关于实体关系.
For CouchDB, I would highly recommend reading this article about Entity Relationships.
我在CouchDB中要注意的一件事是要小心尝试规范化"非关系数据模型.基于文档的存储为您提供了极大的灵活性,将所有内容抽象为您可以想到的尽可能多的文档类型"并不是最好的主意.很多时候,除非您有明确的案例说明存在单独的实体,否则最好将大部分数据保留在同一文档中.
One thing I would note in CouchDB is to be careful of attempting to "normalize" a non-relational data model. The document-based storage offers you a great deal of flexibility, and it's seldom the best idea to abstract everything into as many "document types" as you can think of. Many times, it's best to leave much of your data within the same document unless you have clear cases where separate entities exist.
多对多关系的一个常见用例是实现标记. 文章关于可用于在CouchDB中完成此操作的不同方法.它可能适用于您的要求,可能不适用,但是可能值得一读.
One common use-case of many-to-many relationships is implementing tagging. There are articles about different methods you can use to accomplish this in CouchDB. It may apply to your requirements, it may not, but it's probably worth a read.
这篇关于CouchDB或MongoDB中的多对多关系的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!