All Questions
Data Modeling medium

In a Document Database (like MongoDB), when should you prefer 'Embedding' data (nested array) over 'Referencing' (separate collection with ID link)?

  1. A When the data is logically owned by the parent entity, rarely changes independently, and is almost always accessed as part of the parent's read lifecycle.
  2. B When the relationship between entities is strictly Many-to-Many and the child data must be frequently queried and updated across multiple disparate parents.
  3. C When the embedded dataset is unbounded and expected to grow indefinitely, potentially exceeding the database engine's hard limit on document size.
  4. D When the application requires the ability to perform complex, multi-level JOIN operations that are natively optimized by the underlying document engine.

One system design question a day, with spaced repetition so the ones you miss come back.

Get the app

Related questions