Bird
Raised Fist0
DynamoDBquery~10 mins

DynamoDB vs MongoDB vs Cassandra - Visual Side-by-Side Comparison

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Concept Flow - DynamoDB vs MongoDB vs Cassandra
Start: Choose NoSQL DB
Check Data Model
DynamoDB
Key-Value
Use Cases
Performance
End Comparison
This flow shows choosing between DynamoDB, MongoDB, and Cassandra based on data model, use cases, and strengths.
Execution Sample
DynamoDB
SELECT * FROM DynamoDB_Table WHERE id = '123';
// MongoDB: db.collection.find({id: '123'})
// Cassandra: SELECT * FROM table WHERE id = '123';
Example queries showing how to get data by id in DynamoDB, MongoDB, and Cassandra.
Execution Table
StepDatabaseQuery SyntaxData ModelUse Case ExamplePerformance Notes
1DynamoDBGetItem with Partition KeyKey-Value StoreFast lookups by keySingle-digit ms latency, fully managed
2MongoDBfind({id: '123'})Document Store (JSON-like)Flexible schema, complex queriesGood for varied data, moderate latency
3CassandraSELECT * FROM table WHERE id = '123'Wide-Column StoreHigh write throughput, large scaleHighly scalable, eventual consistency
4ComparisonN/AN/AChoose based on needsDynamoDB: managed, MongoDB: flexible, Cassandra: scalable
5EndN/AN/AN/ADecision depends on data model and scale
💡 Comparison ends after summarizing key differences and use cases.
Variable Tracker
DatabaseData ModelQuery StyleStrength
DynamoDBKey-ValueGetItem/QueryManaged, low latency
MongoDBDocumentfind()Flexible schema
CassandraWide-ColumnCQL SELECTScalable, high throughput
Key Moments - 3 Insights
Why does DynamoDB use a key-value model while MongoDB uses documents?
DynamoDB is optimized for fast lookups using keys (see execution_table row 1), while MongoDB stores JSON-like documents allowing flexible and nested data (row 2). This affects how you design your data.
Why is Cassandra considered more scalable than MongoDB?
Cassandra's wide-column model and distributed architecture (execution_table row 3) allow it to handle very large data and many writes across many servers, unlike MongoDB which is less distributed by default.
Can you use complex queries in DynamoDB like in MongoDB?
No, DynamoDB focuses on simple key-based queries for speed (row 1), while MongoDB supports complex queries on document fields (row 2). This limits DynamoDB's query flexibility.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, which database uses a document data model?
ADynamoDB
BMongoDB
CCassandra
DAll three
💡 Hint
Check the 'Data Model' column in execution_table row 2.
At which step does the table mention 'high write throughput'?
AStep 3
BStep 2
CStep 1
DStep 4
💡 Hint
Look at the 'Use Case Example' column for Cassandra in execution_table.
If you want a fully managed service with low latency, which database fits best?
AMongoDB
BCassandra
CDynamoDB
DNone of these
💡 Hint
Refer to the 'Performance Notes' for DynamoDB in execution_table row 1.
Concept Snapshot
DynamoDB: Key-value, fully managed, low latency.
MongoDB: Document store, flexible schema, complex queries.
Cassandra: Wide-column, highly scalable, high write throughput.
Choose based on data model, query needs, and scale.
DynamoDB best for simple key lookups.
MongoDB best for flexible, nested data.
Cassandra best for massive scale and writes.
Full Transcript
This visual compares three popular NoSQL databases: DynamoDB, MongoDB, and Cassandra. It starts by choosing a NoSQL database, then checks their data models: DynamoDB uses key-value, MongoDB uses document, and Cassandra uses wide-column. Each has different query styles and use cases. DynamoDB is fully managed and fast for key lookups. MongoDB offers flexible schema and complex queries. Cassandra excels at scalability and high write throughput. The execution table shows example queries and performance notes. Variable tracking summarizes their key traits. Key moments clarify common confusions about data models, scalability, and query complexity. The quiz tests understanding of data models, use cases, and performance. The snapshot summarizes key points for quick reference.

Practice

(1/5)
1. Which database is best known for automatic scaling and simple key-value access?
easy
A. Cassandra
B. DynamoDB
C. MongoDB
D. MySQL

Solution

  1. Step 1: Understand DynamoDB's core feature

    DynamoDB is designed for simple key-value access and automatic scaling.
  2. Step 2: Compare with other databases

    MongoDB focuses on flexible document storage, Cassandra on high availability for huge data.
  3. Final Answer:

    DynamoDB -> Option B
  4. Quick Check:

    Automatic scaling + key-value = DynamoDB [OK]
Hint: Automatic scaling with key-value means DynamoDB [OK]
Common Mistakes:
  • Confusing MongoDB's flexible documents with key-value simplicity
  • Thinking Cassandra automatically scales like DynamoDB
  • Choosing MySQL which is relational, not key-value
2. Which of the following is the correct way to describe MongoDB's data model?
easy
A. Column-family store with automatic partitioning
B. Simple key-value pairs with fixed schema
C. Flexible document storage with rich queries
D. Relational tables with strict schema

Solution

  1. Step 1: Identify MongoDB's data model

    MongoDB stores data as flexible JSON-like documents allowing rich queries.
  2. Step 2: Eliminate other options

    Column-family store describes Cassandra, key-value with fixed schema fits DynamoDB less, relational tables fit SQL databases.
  3. Final Answer:

    Flexible document storage with rich queries -> Option C
  4. Quick Check:

    MongoDB = flexible documents + rich queries [OK]
Hint: MongoDB = flexible JSON documents + rich queries [OK]
Common Mistakes:
  • Confusing MongoDB with Cassandra's column-family model
  • Thinking MongoDB uses fixed schema like relational DB
  • Mixing key-value with document storage
3. Given a large dataset requiring high availability and fast writes across multiple data centers, which database is most suitable?
medium
A. MongoDB
B. DynamoDB
C. SQLite
D. Cassandra

Solution

  1. Step 1: Analyze requirements for high availability and multi-datacenter writes

    Cassandra is designed for huge data with high availability and multi-region replication.
  2. Step 2: Compare other options

    MongoDB supports replication but less optimized for huge scale multi-datacenter writes; DynamoDB is scalable but less focused on multi-datacenter writes; SQLite is local and not distributed.
  3. Final Answer:

    Cassandra -> Option D
  4. Quick Check:

    High availability + multi-datacenter = Cassandra [OK]
Hint: Huge data + multi-region writes = Cassandra [OK]
Common Mistakes:
  • Choosing DynamoDB for multi-datacenter writes
  • Confusing SQLite as distributed database
  • Assuming MongoDB handles huge multi-region writes best
4. You try to use MongoDB's flexible document queries on DynamoDB but get errors. What is the likely cause?
medium
A. DynamoDB does not support flexible document queries like MongoDB
B. DynamoDB requires SQL syntax for queries
C. MongoDB uses column-family data model incompatible with DynamoDB
D. DynamoDB only supports relational tables

Solution

  1. Step 1: Understand query capabilities of DynamoDB

    DynamoDB supports key-value and simple queries but not rich flexible document queries like MongoDB.
  2. Step 2: Eliminate incorrect causes

    DynamoDB does not use SQL syntax, is not column-family, and is not relational.
  3. Final Answer:

    DynamoDB does not support flexible document queries like MongoDB -> Option A
  4. Quick Check:

    DynamoDB lacks MongoDB's flexible queries [OK]
Hint: DynamoDB lacks MongoDB's rich document query support [OK]
Common Mistakes:
  • Assuming DynamoDB uses SQL syntax
  • Confusing data models between MongoDB and Cassandra
  • Thinking DynamoDB supports relational tables
5. You need a database for an app that requires flexible JSON documents, automatic scaling, and global availability. Which approach best fits this need?
hard
A. Use DynamoDB with JSON support and global tables
B. Use MongoDB with sharding and replica sets only
C. Use Cassandra with column-family tables and no JSON support
D. Use SQLite with local JSON extensions

Solution

  1. Step 1: Identify features needed

    The app needs flexible JSON documents, automatic scaling, and global availability.
  2. Step 2: Match features to databases

    DynamoDB supports JSON documents, automatic scaling, and global tables for availability. MongoDB supports JSON but global availability requires extra setup and scaling is manual. Cassandra lacks native JSON support and SQLite is local only.
  3. Final Answer:

    Use DynamoDB with JSON support and global tables -> Option A
  4. Quick Check:

    JSON + auto scale + global = DynamoDB [OK]
Hint: DynamoDB global tables + JSON = best for scaling + availability [OK]
Common Mistakes:
  • Choosing MongoDB without considering scaling complexity
  • Ignoring Cassandra's lack of JSON support
  • Selecting SQLite which is not distributed