Model Tree Structures with Parent References

Overview

A tree-alike data model structure in mongo storing references to “parent”nodes in the child nodes.

Pattern

The Parent Reference pattern stores each tree node in a document; in addition to the tree, the document stores the id of the node’s parent.

Consider the following hierarchy of categories:

The following example models the tree using Parent

Reference, storing the reference to the parent category in the field parent:

Model Tree Structures with Child References

Overview

A tree-alike data model in mongo store references in the parent-nodes to children nodes.

Pattern

Consider the following hierarchy of categories:

The following example models the tree using Child References, storing the reference to the node’s children in the field children:

Model Tree Structures with an Array of Ancestors

Pattern

Consider the following hierarchy of categories:

The following examples models the tree using Array of Ancestors.

Model Tree Structures with Materialized Paths

Pattern

Consider the following hierarchy of categories:

The following examples models the tree using Materialized Path, storing the path in the field path. The path string uses the comma , as a delimiter:

Model Tree Structures with Nested Sets

Overview

A tree-alike data model optimize discovering subtrees at the expense of tree mutability.

Pattern

The Nested Sets pattern identifies each node in the tree as stops in a round-trip traverse of tree. The application visits each node in the tree twice. First during the initial trip, and second during the return trip. The Nested Sets pattern stores each tree each tree node in a document. In addition to the tree node, document stores the id of node’s parent, the node’s initial stop in the left field, and its return stop in the right end.

Consider the following hierarchy of categories:

The following example models the  tree using Nested Sets:

转载于:https://www.cnblogs.com/hotbaby/p/4867911.html

MongoDB 树形模型相关推荐

  1. 机器学习之树形模型:决策树

    决策树 常见的树形模型(随机森林.GBDT.XGBoost),树形的基础是"决策树". "决策树"特点:易理解.易构建.速度快 分类 分类决策树 输出的结果为具 ...

  2. mongodb线程池_常用高并发网络线程模型设计及MongoDB线程模型优化实践

    服务端通常需要支持高并发业务访问,如何设计优秀的服务端网络IO工作线程/进程模型对业务的高并发访问需求起着至关重要的核心作用. 本文总结了了不同场景下的多种网络IO线程/进程模型,并给出了各种模型的优 ...

  3. 机器学习里面的树形模型

    1. 决策树不用考虑scaler. 2, xgboost 缺失值都可以不用考虑. 3.libSVM的数据格式及使用方法总结 首先介绍一下 libSVM的数据格式 Label 1:value 2:val ...

  4. 使用Spring Boot和MongoDB构建一个React式应用程序

    "我喜欢编写身份验证和授权代码." 〜从来没有Java开发人员. 厌倦了一次又一次地建立相同的登录屏幕? 尝试使用Okta API进行托管身份验证,授权和多因素身份验证. 如果您要 ...

  5. 使用Spring Boot和MongoDB构建一个反应式应用程序

    "我喜欢编写身份验证和授权代码." 〜从来没有Java开发人员. 厌倦了一次又一次地建立相同的登录屏幕? 尝试使用Okta API进行托管身份验证,授权和多因素身份验证. 如果您要 ...

  6. 李宏毅的可解释模型——三个任务

    1.问题 观看了李宏毅老师的机器学习进化课程之可解释的机器学习,课程中对主要是针对黑盒模型进行白盒模型转化的技巧和方法进行了简单介绍,详细细节可以参考<Interpretable Machine ...

  7. Spring Data MongoDB示例

    Spring Data MongoDB示例 欢迎使用Spring Data MongoDB示例.Spring Data MongoDB是将Spring Framework与最广泛使用的NoSQL数据库 ...

  8. MongoDB 进阶模式设计

    原文链接:http://www.mongoing.com/mongodb-advanced-pattern-design 12月12日上午,TJ在开源中国的年终盛典会上分享了文档模型设计的进阶技巧,就 ...

  9. mongodb 字符串转bson_大数据存储技术选型(六)--Mongodb专题介绍

    之前我曾有过一次mongodb的介绍,但那是年少无知,对mongo认识得不够充分,所以当时那篇专题介绍只是介绍了一个大概的轮廓就草草敷衍了事了.对此我做了深刻的反省与自我批评.接下来,今天就mongo ...

最新文章

  1. 一篇叫做决心书的文章
  2. python基础学习笔记2
  3. The Best Way to Export an SVG from Sketch
  4. 设计模式在实际业务应用中的介绍之2——业务工厂
  5. android扩散波动动画,使用WebGL制作图片的像素脉冲波(粒子化扩散波动)动画特效...
  6. 给小组新成员的一份信
  7. 如何使用UIAutomation进行iOS 自动化测试(Part II)
  8. 公式经纬度换算度分秒,度分秒换算经纬度
  9. 好用的轻量级UI控件库
  10. 笔记本处理器排名_上半年最受欢迎处理器TOP10榜单:AMD终进榜,9代酷睿无缘前10...
  11. 用unity高通Vuforia AR制作自定义扫描物体
  12. 关于网络异常的英文词汇总结
  13. Java语言基本语法————变量和常量数据类型
  14. enovia PLM : add new value to SPEO
  15. 显示器经典故障以及处理办法
  16. AG9311/AG9310 Type-C转HDMI设计方案|替代AG9310/AG9311芯片|GSV2201可完全替代兼容AG9310/AG9311
  17. 这样Review代码牛逼啦!
  18. win7最适合的杀毒软件(电脑适合用什么杀毒软件)
  19. 联想e470锁定计算机,联想E470c电脑设置硬盘启动的方法,你值得拥有!
  20. 什么软件可以文字转语音?这些软件值得收藏

热门文章

  1. 跟我学XSL(二) -XSL的运算符
  2. c语言flash里能存文件吗,STM32内部FLASH打包读写
  3. vue中slot(插槽)详解,slot、slot-scope和v-slot
  4. 自己动手写一个nodejs的日志生成器
  5. javascript引用类型
  6. MobaXterm工具连接Linux服务器入门使用手册,国产化泰山服务器连接工具使用演示
  7. Python 技术篇 - 用xlrd库和xlwt库操作excel,对excel进行读取和写入实例演示
  8. CTFshow 命令执行 web65
  9. padarray函数
  10. oracle rman 架构图,图解Oracle RMAN备份入门