MongoDB Schema Design
Schema-Less vs Schema-Full
MongoDB is schema-flexible, but you should still design consistent schemas:
Learning Objectives
Lesson Outline
MongoDB is schema-flexible, but you should still design consistent schemas:
Unlike SQL, MongoDB schema should be designed around how you query data.
| Consideration | Embed | Reference |
|---|---|---|
| Data relationship | Contains (1:1, 1:few) | References (1:many, many:many) |
| Access pattern | Always accessed together | Accessed separately |
| Data size | Embedded data is small | Data can grow large |
| Update frequency | Rarely updated | Frequently updated |
| Atomicity need | Need atomic updates | Can use transactions |