嵌入更适合:
- 小子文档
- 数据不会定期更改
- 最终一致性是可以接受的
- 少量增长的文档
- 您通常需要执行第二次查询才能获取的数据
- 快速阅读速度
- Small subdocuments
- Data that does not change regularly
- WHen eventual consistency is acceptable
- Document that grow by a small amount
- Data that you'll often need to perform asecond query to fetch
- Fast reading speed
参考文献更好
- 大子文档
- 易失数据
- 需要立即进行紧急情况
- 文档大量增长
- 您经常从文档中排除的数据
- 快速命令速度
- Large subdocuments
- Volatile data
- When immediate consitency is necessary
- Document grow with a large amount
- Data that you often exclude from document
- Fast write speed
-摘自《 Mongodb权威指南》
-From 《Mongodb Definitive Guide》
参考像
{'_id':ObjectId( 123),'cousin':ObjectId( 456)}
一样,它的表亲通过ObjectId来引用它,就像SQL中的外键一样。
Reference is something like
{'_id':ObjectId("123"),'cousin':ObjectId("456")}
It refers to his cousin through its ObjectId something like foreign key in SQL.