Lesson 15 / 22

Embedding vs Referencing

Two ways to model relationships between data.

Embedding

Embedding nests related data directly inside the parent document — best when the data is read together and stays small.

Referencing

Referencing stores just an _id pointing to a document in another collection — best for large, unbounded, or independently-updated data.

A rule of thumb

If data is always read together and won't grow unbounded — embed. If it grows large, is shared, or is updated separately — reference.