官术网_书友最值得收藏!

References

Using references (https://docs.mongodb.com/manual/reference/database-references/), it is possible to create a series of related collections in order to establish a normalized (https://docs.mongodb.com/manual/core/data-model-design/#normalized-data-models) data model. In the following diagram, a normalized data model is established by defining a field purchId, which forms a reference between the Customer collection and Purchases. Further, the field itemId can serve as a reference between Purchases and Products:

By imposing an SQL-esque solution on a MongoDB dataset, however, you defeat the purpose of using a NoSQL database. Unless your database driver provides support for DBRefs (https://docs.mongodb.com/manual/reference/database-references/#dbrefs), which allows for an embedded link between collections, you are forced to write code to traverse the references manually, which introduces the very overhead you wanted to avoid by choosing MongoDB in the first place!

As of this writing, only half of the programming language drivers available provide support for DBRefs:
  • Provides DBRef support: C#, Java, Node.js, Perl, Python, Ruby
  • Does not provide DBRefs support: C, C++, Haskell, PHP, Scala
主站蜘蛛池模板: 雅江县| 当雄县| 西城区| 托里县| 沐川县| 翁源县| 平顺县| 闸北区| 绍兴县| 壶关县| 黄龙县| 巫溪县| 元阳县| 新巴尔虎右旗| 巴林左旗| 棋牌| 新余市| 沙雅县| 南木林县| 柳河县| 通城县| 邵阳市| 贵港市| 峨山| 土默特左旗| 禄丰县| 江口县| 林周县| 海门市| 靖远县| 盖州市| 安图县| 灌阳县| 团风县| 仪征市| 当雄县| 库伦旗| 株洲县| 靖安县| 高密市| 修水县|