MongoDBQuestion 06 of 8
Relationships between documents
Answer out loud or in your head first, then compare.
Answer
The two basic options are embedding data and referencing other documents.
Embedding: data that's read together lives in one document, e.g. a delivery address stored in the order.
Reference: I store the ID of the related document, e.g. customerId, when the data has its own lifecycle or many relationships.
To be precise: $lookup lets you join data in an aggregation. populate in Mongoose is a library feature, not an automatic equivalent of a database foreign key.
Pitfall: embedding simplifies reads but can duplicate data. References need extra fetching and care about consistency.
How did it go? Be honest — “Not yet” puts the question on your review list.