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.提出了一种数据模型,通过在“子”Node中存储对“父”节点的引用,以树状结构组织文档。
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.提出了一种数据模型,通过在“父”Node中存储对“子”节点的引用,以树状结构组织文档。
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.除了树节点外,每个文档还以字符串形式存储Node祖先或路径的_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.这优化了发现子树的过程,但牺牲了树的可变性。