Relationships in MongoDB
5 min read
Module Overview
What You’ll Learn
- Model relationships in MongoDB by embedding related data
- Model relationships in MongoDB by referencing other documents
- Decide which approach fits a given relationship, and why
💡 Why this module matters: MongoDB has no foreign keys or joins in the relational sense (Module 5). Relationships are modeled by a real design choice, embedding or referencing, this module covers both, and how to decide between them.
What’s Covered
- Embedding, nesting related data directly inside a document.
- Referencing, storing an ID and querying the related document separately.
- Trade-offs, read performance, document size limits, and data duplication.
- Choosing an approach, matching the relationship’s shape to embedding or referencing.
Hands-On
By the end of this module, you’ll have modeled the same relationship both ways, embedded and referenced, against a real MongoDB database, and be able to explain when to reach for each.
This is the final MongoDB-specific module in this course. Next module: the capstone, a full CRUD API backed by a real database.