现在把 MongoDB 这座弹性档案仓重新连成一张图:
MongoDB 弹性档案仓
|
|-- Database(库区)
| |
| |-- Collection(档案柜)
| | |
| | |-- Document(档案袋)
| | | |
| | | |-- Field(字段)
| | | |-- Embedded Document(子档案)
| | | |-- Array(清单)
| | |
| | |-- Index(检索目录)
| |
| |-- Aggregation Pipeline(档案加工流水线)
| |-- Transaction(多档案联动修改机制)
|
|-- BSON(底层档案材料)
|-- Flexible Schema(可演进结构)
|-- Schema Design(按访问路径摆放档案)
|-- Embed / Reference(装一起 or 用编号关联)最后把一套实战心法压成六句:
- 先想“业务对象长什么样”,再想集合怎么建。
- 先想“最关键查询是什么”,再决定嵌套还是引用。
- 一起访问的数据,尽量放一起。
- 会无限增长或独立存在的数据,谨慎拆出去。
- 关键查询必须有索引,但索引不是越多越好。
- 事务是能力,不是逃避建模的理由。
如果你能用“弹性档案仓”的方式去理解 MongoDB,你就不会只把它当成“没表结构的 JSON 存储器”,而会真正掌握它的建模思想。
#官方来源链接清单
- MongoDB Manual 总入口:https://www.mongodb.com/docs/manual/
- Documents:https://www.mongodb.com/docs/manual/core/document/
- BSON Types:https://www.mongodb.com/docs/manual/reference/bson-types/
- Data Modeling in MongoDB:https://www.mongodb.com/docs/manual/data-modeling/
- Best Practices for Data Modeling:https://www.mongodb.com/docs/manual/data-modeling/best-practices/
- Embedded Data Versus References:https://www.mongodb.com/docs/manual/data-modeling/concepts/embedding-vs-references/
- Schema Validation:https://www.mongodb.com/docs/manual/core/schema-validation/
- Index Types:https://www.mongodb.com/docs/manual/core/indexes/index-types/
- Create an Index:https://www.mongodb.com/docs/manual/core/indexes/create-index/
- Aggregation Pipeline:https://www.mongodb.com/docs/manual/core/aggregation-pipeline/
- db.collection.find():https://www.mongodb.com/docs/manual/reference/method/db.collection.find/
- Update Methods:https://www.mongodb.com/docs/manual/reference/update-methods/
- Update Operators:https://www.mongodb.com/docs/manual/reference/mql/update/
- Atomicity and Transactions:https://www.mongodb.com/docs/manual/core/write-operations-atomicity/
- Transactions:https://www.mongodb.com/docs/manual/core/transactions/index.html