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

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
主站蜘蛛池模板: 定边县| 特克斯县| 永寿县| 桃园县| 香格里拉县| 永宁县| 分宜县| 陕西省| 铁岭市| 台中市| 布拖县| 来宾市| 建宁县| 枞阳县| 惠水县| 巴塘县| 镇宁| 衡阳县| 新乐市| 沿河| 小金县| 琼海市| 榕江县| 新津县| 沾化县| 祁连县| 常州市| 咸阳市| 阳春市| 高邑县| 张家口市| 济源市| 宝丰县| 西乌珠穆沁旗| 鹤庆县| 长海县| 辉县市| 嵊泗县| 台安县| 那曲县| 资中县|