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

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
主站蜘蛛池模板: 施甸县| 赤城县| 时尚| 平谷区| 彭泽县| 丹江口市| 阜南县| 黎城县| 镇远县| 沐川县| 白城市| 浙江省| 鄯善县| 亚东县| 佛冈县| 祁门县| 福海县| 泌阳县| 桐城市| 石阡县| 朝阳县| 安顺市| 绥滨县| 梧州市| 张家川| 杭锦旗| 九江市| 松潘县| 棋牌| 大石桥市| 南江县| 霍林郭勒市| 府谷县| 苗栗市| 东乌珠穆沁旗| 邵阳县| 原平市| 南通市| 清丰县| 永定县| 确山县|