Need Assistance?

support@tutorialshub.in

Data Modeling & Schema Design

Embedding vs Referencing

ADVERTISEMENT
MongoDB Free Lesson
5 min read
ADVERTISEMENT

The most important design decision in MongoDB is whether to embed related data inside a single document or reference it in another collection.

  • Embed when data is read together, has a small bounded size (e.g., user address, order line items), and belongs strictly to the parent.
  • Reference (store ObjectId) when data grows unboundedly (e.g., thousands of comments), is shared across many parents, or is updated independently.
ADVERTISEMENT
Hi, I'm Tuby! Here to help you