Database Manual / Data Modeling / Data Model Examples and Patterns

Model Tree Structures模型树结构

MongoDB allows various ways to use tree data structures to model large hierarchical or nested data relationships.MongoDB允许使用树数据结构对大型分层或嵌套数据关系进行建模。

Tree data model for a sample hierarchy of categories.
Model Tree Structures with Parent References具有父引用的模型树结构
Presents a data model that organizes documents in a tree-like structure by storing references to "parent" nodes in "child" nodes.提出了一种数据模型,通过将对“父”节点的引用存储在“子”节点中,以树状结构组织文档。
Model Tree Structures with Child References具有子引用的模型树结构
Presents a data model that organizes documents in a tree-like structure by storing references to "child" nodes in "parent" nodes.提出了一种数据模型,通过将对“子”节点的引用存储在“父”节点中,以树状结构组织文档。
Model Tree Structures with an Array of Ancestors具有祖先数组的模型树结构
Presents a data model that organizes documents in a tree-like structure by storing references to "parent" nodes and an array that stores all ancestors.展示了一个数据模型,该模型通过存储对“父”节点的引用和存储所有祖先的数组,以树状结构组织文档。
Model Tree Structures with Materialized Paths具有物化路径的模型树结构
Presents a data model that organizes documents in a tree-like structure by storing full relationship paths between documents. In addition to the tree node, each document stores the _id of the nodes ancestors or path as a string.展示了一个数据模型,通过存储文档之间的完整关系路径,以树状结构组织文档。除了树节点外,每个文档还将节点祖先的_id或路径存储为字符串。
Model Tree Structures with Nested Sets嵌套集的模型树结构
Presents a data model that organizes documents in a tree-like structure using the Nested Sets pattern. This optimizes discovering subtrees at the expense of tree mutability.展示了一个数据模型,该模型使用嵌套集模式以树状结构组织文档。这以牺牲树的可变性为代价优化了子树的发现。