Skip to main content

What is a nested document (embedded document)?

An embedded document is a document stored as a field inside another document. It lets you describe related data within a single structure instead of spreading it across separate entities.

Example:

json
{ "name": "Alex", "address": { "city": "Berlin", "street": "Main St.", "house": 12 } }

Key characteristics

  1. Stored inside the main document There's no separate collection or record, everything lives in one object.
  2. Convenient for related data It fits "one-to-one" entities or "anything that logically belongs to the object".
  3. Cuts down the number of queries No JOIN is needed, the data is read straight from one document.

Summary: an embedded document is a way to store related data entirely inside one MongoDB document, preserving structure and simplifying access.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.