Section 1Notes
Quick notes are visible here first. Each note also links out to the Medium blog for deeper reading.
MongoDB schema design starts with how the application reads and writes data, not just entity diagrams.
- Embed data when it is read together, owned by one parent, and bounded in size.
- Reference data when it is large, reused independently, or changes frequently across many parents.
- Watch document growth because the 16 MB document limit and large arrays can become performance problems.
Open Medium noteIndexes make filters, sorts, and joins practical, while aggregation pipelines should reduce data early.
- Place $match and $project early so later pipeline stages process less data.
- Compound indexes should match equality filters, then sort fields, then range filters where possible.
- Use explain plans to verify whether an index is used and whether a sort happens in memory.
Open Medium noteReplica sets improve availability; sharding splits data across machines for larger write and storage scale.
- Replica sets have a primary for writes and secondaries for replication and failover.
- A good shard key has high cardinality, even distribution, and aligns with important query patterns.
- Poor shard keys create hot shards, scatter-gather queries, and painful rebalancing.
Open Medium noteSection 2Interview Questions
Filter by category, search the answers, mark reads, and keep only the questions that matter right now.