- 在规范化数据模型中,地址文档包含对顾客文档的引用。 ```json // address document { street: “123 Fake Street”, city: “Faketon”, state: “MA”, zip: “12345”, patron_id: “joe”, // reference to patron document }
// patron document { _id: “joe”, name: “Joe Bookreader” }
- 使用嵌入式数据模型,您的应用程序可以通过一个查询来检索完整的顾客信息。
```json
{
_id: "joe",
name: "Joe Bookreader",
address: {
street: "123 Fake Street",
city: "Faketon",
state: "MA",
zip: "12345"
}
}
- 嵌入式文档模式的潜在问题是,它可能导致大型文档包含应用程序不需要的字段。