Command Palette

Search for a command to run...

PHASE 8Intermediate ~6 min· topic 8 of 10

Topic 8.8

Document Databases

In one line

MongoDB-style: JSON documents, embedded nesting, flexible schema, secondary indexes, and Atlas-scale ops.

0/10 · 0%

Think of it like this

A folder that holds a person's entire profile in one page — photo, address, and recent orders all stapled together — so you grab the whole thing in one pull instead of digging through five different filing cabinets.

Key ideas

  1. 01

    Unit of storage: a document (JSON/BSON) — related data embedded together → one read, no join.

  2. 02

    Embed vs reference: embed when read-together & bounded growth; reference when shared / unbounded (comments on a post).

  3. 03

    Indexes: single-field, compound, and text; schema flexibility means index discipline is on YOU.

  4. 04

    Transactions: single-document atomic; multi-document transactions exist (4.0+) but cost and scale poorly — design around them.

  5. 05

    Horizontal scale: shard by shard key; hot documents are a real problem (8.5) in document stores too.

  6. 06

    Interview framing: 'profile with orders embedded' is the canonical happy case; 'billions of events' is not.

Java / Spring map

  • →

    Spring Data MongoDB: @Document, MongoTemplate aggregate pipelines, DBRef for references.

Explain without notes

01

Orders embedded inside a user document: when does that become a bad idea? Name two symptoms.

Practice

01

Model a notification-preference profile as a document and justify embedding vs referencing.

Trade-offs

  • ↔

    Flexible schema = schema drift debt; the team becomes the schema. Pin it in review.

Run it in production

You've designed it. Now build, operate, and break the same idea hands-on in the DevOps courses:

Completion checklist

  • I can embed-or-reference with the read-together + growth rules in hand.

Back to phase