MongoDB vs DynamoDB vs Cassandra vs Postgres JSONB
Fast recall
Quick revision
Core answer
Pragmatic NoSQL selection and avoiding cargo-cult 'MongoDB for scale'
Choosing MongoDB for relational data, underestimating Postgres JSONB, or picking DynamoDB without modeling access patterns
Discuss single-table design, PACELC classifications, MongoDB aggregation pipeline, Cassandra LSM write path, GIN indexes, and polyglot persistence
Interview-ready guide
Interview answer
Frame the four tools
- Postgres JSONB: relational + flexible JSON; 2026 default
- MongoDB: document-first; rich aggregation; built-in sharding
- DynamoDB: AWS-managed KV + doc at massive scale; zero ops
- Cassandra/Scylla: wide-column; extreme write throughput; tunable consistency
Walk the decision
- Data shape first — relational, document, KV, wide-column
- Access patterns next — arbitrary queries vs known keys
- Scale numbers — single-node Postgres goes far
- Consistency needs — strong vs tunable
- Ops model — managed vs self-host
Mention cost
- DynamoDB on-demand cheap at low volume, expensive at high
- Cassandra self-host cheap compute but real DBA cost
- Atlas/Aurora premium but ops-light
Close with pragmatism
- Polyglot persistence is fine — each store does its job
- Don't confuse 'need scale' with 'need NoSQL'
MongoDB vs DynamoDB vs Cassandra vs Postgres JSONB
Direct Answer
Four tools, four shapes. Postgres JSONB is the 2026 default for 'flexible schema inside a relational DB' — indexable JSON with GIN, transactions, joins; fits 80% of MongoDB use cases. MongoDB shines when documents are genuinely the primary model, shapes vary, and you want its aggregation pipeline and sharding. DynamoDB is AWS-managed KV + document at massive scale with zero ops but access-pattern-first schema. Cassandra / ScyllaDB serves extreme write throughput (100K+/sec) with linear scaling and tunable consistency. The rule of thumb: start with Postgres, add JSONB where needed; pick MongoDB for document-first; DynamoDB for AWS-native KV at scale; Cassandra only for massive writes.
Common Mistakes & Pitfalls
Choosing MongoDB for relational data, underestimating Postgres JSONB, or picking DynamoDB without modeling access patterns
Check your understanding
Answer these without looking back at the article.
- What is DynamoDB single-table design and when is it appropriate?
- How do GIN indexes on Postgres JSONB compare to MongoDB indexes?
- When does sharding MongoDB make sense and how do you pick the shard key?
- Why do Cassandra tombstones cause performance problems?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.