Summary of Best Practices
- "First class" objects, that are at top level, typically have their own collection.
- Line item detail objects typically are embedded.
- Objects which follow an object modelling "contains" relationship should generally be embedded.
- Many to many relationships are generally done by linking.
- Collections with only a few objects may safely exist as separate collections, as the whole collection is quickly cached in application server memory.
- Embedded objects are a bit harder to link to than "top level" objects in collections.
- It is more difficult to get a system-level view for embedded objects. When needed an operation of this sort is performed by using MongoDB's map/reduce facility.
- If the amount of data to embed is huge (many megabytes), you may reach the limit on size of a single object. See alsoGridFS.
- If performance is an issue, embed.
本文概述了数据模型设计的最佳实践,包括如何使用顶级对象、详细项细节对象、嵌入式对象以及处理复杂关系和性能优化的方法。重点讨论了在数据集大小和性能考量下,选择将对象嵌入或作为独立集合的策略。
1138

被折叠的 条评论
为什么被折叠?



