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

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
主站蜘蛛池模板: 孝昌县| 肥城市| 泸西县| 高唐县| 伊宁县| 泰宁县| 航空| 林口县| 田阳县| 清涧县| 清涧县| 龙江县| 密山市| 海淀区| 武平县| 黎川县| 巩留县| 阿拉善左旗| 新晃| 新营市| 永清县| 理塘县| 南安市| 论坛| 宿迁市| 浮山县| 汶川县| 遂昌县| 延庆县| 买车| 台州市| 宜都市| 剑川县| 朝阳市| 惠安县| 宜章县| 平陆县| 南岸区| 加查县| 大同市| 溆浦县|