MongoDB
A document database that stores flexible, JSON-shaped records.
MongoDB is a document-oriented database. Instead of rows in a table, it stores JSON-like documents that can nest objects and arrays, grouped into collections that do not require every document to share one fixed shape.
- Difficulty
- intermediate
- Time
- 15+ hours
- Sections written
- 26
Why it matters
- The document shape maps closely onto objects in application code, so there is often less translation between what you store and what you work with.
- Nesting related data removes joins for data that is always read together.
- It scales horizontally through sharding, and stays available through replica sets, without redesigning the data model.
- It is one of the most common databases behind Node.js and Python backends, so it pairs directly with two of the other topics here.
Where it is used
- Application backends — user profiles, catalogs, content, events
- Real-time analytics and event/telemetry pipelines
- Content management and catalog systems with varied, evolving shapes
- Multi-tenant SaaS platforms
The big picture
- Documents — BSON, nested fields
- leads to Collections (grouped into)
- Collections — grouped, flexible shape
- leads to Indexes (looked up via)
- Indexes — what makes queries fast
- leads to Aggregation (feed)
- Aggregation — transform and analyze
- leads to Replica sets / shards (runs across)
- Replica sets / shards — availability and scale

