Bird
Raised Fist0
DynamoDBquery~10 mins

NoSQL vs relational database comparison in DynamoDB - 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 - NoSQL vs relational database comparison
Start
Choose Database Type
Relational DB
Tables with Rows
Fixed Schema
Use SQL Queries
Strong ACID
Good for Complex
Relationships
End
This flow shows the choice between relational and NoSQL databases, highlighting their structure, schema, query style, consistency, and use cases.
Execution Sample
DynamoDB
-- Relational DB example
SELECT * FROM Users WHERE Age > 30;

-- NoSQL (DynamoDB) example
aws dynamodb scan --table-name Users --filter-expression "Age > :age" --expression-attribute-values '{":age":{"N":"30"}}'
This shows a simple query to get users older than 30 in both relational SQL and DynamoDB NoSQL style.
Execution Table
StepDatabase TypeStructureSchemaQuery StyleConsistencyUse Case
1RelationalTables with rows and columnsFixed schema (defined columns)SQL queriesStrong ACID (Atomicity, Consistency, Isolation, Durability)Good for complex relationships and transactions
2NoSQL (DynamoDB)Tables with items (key-value pairs)Flexible schema (attributes can vary)API calls or query expressionsEventual consistency by default, can be configured for strong consistencyGood for big data, high scalability, flexible data models
3RelationalRows must follow schemaSchema changes require migrationsJoins supportedTransactions supportedStructured data with relations
4NoSQL (DynamoDB)Items can have different attributesSchema changes easy, no migrations neededNo joins, denormalization commonLimited transactions (ACID in some cases)Unstructured or semi-structured data
5RelationalScaling vertically (bigger servers)Schema enforces data integrityComplex queries possibleStrong consistency alwaysFinancial, ERP, CRM systems
6NoSQL (DynamoDB)Scaling horizontally (more servers)Flexible for evolving dataSimple queries, no complex joinsEventual consistency for speedWeb apps, IoT, real-time analytics
7End-----
💡 Comparison ends after listing key differences and use cases for both database types.
Variable Tracker
AspectRelational DBNoSQL (DynamoDB)
StructureTables with rows and columnsTables with items (key-value pairs)
SchemaFixed, predefined columnsFlexible, attributes vary per item
Query StyleSQL languageAPI calls or expressions
ConsistencyStrong ACIDEventual by default, optional strong
ScalingVertical scalingHorizontal scaling
Use CaseComplex relationships, transactionsBig data, scalability, flexible data
Key Moments - 3 Insights
Why does NoSQL allow flexible schema while relational databases do not?
Because NoSQL stores data as items with varying attributes (see execution_table rows 2 and 4), it does not require all data to fit a fixed column structure like relational tables do (rows 1 and 3).
How does consistency differ between relational and DynamoDB NoSQL?
Relational databases guarantee strong ACID consistency (rows 1 and 5), while DynamoDB defaults to eventual consistency for speed but can be configured for strong consistency (rows 2 and 6).
Why are joins common in relational but not in NoSQL?
Relational databases support joins to combine tables (row 3), but NoSQL databases like DynamoDB do not support joins and instead use denormalized data to avoid complex queries (row 4).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step is it mentioned that NoSQL uses flexible schema?
AStep 2
BStep 3
CStep 1
DStep 5
💡 Hint
Check the 'Schema' column for NoSQL in step 2.
According to variable_tracker, which database type uses vertical scaling?
ANoSQL (DynamoDB)
BRelational DB
CBoth
DNeither
💡 Hint
Look at the 'Scaling' row in variable_tracker.
From execution_table, which database type supports complex joins?
ABoth
BNoSQL (DynamoDB)
CRelational DB
DNone
💡 Hint
See the 'Query Style' and 'Use Case' columns in step 3.
Concept Snapshot
NoSQL vs Relational Databases:
- Relational: fixed schema, tables with rows/columns, SQL queries, strong ACID consistency.
- NoSQL (DynamoDB): flexible schema, key-value items, API queries, eventual consistency by default.
- Relational scales vertically; NoSQL scales horizontally.
- Use relational for complex relationships; NoSQL for big data and scalability.
- NoSQL avoids joins; relational supports them for complex queries.
Full Transcript
This visual execution compares NoSQL and relational databases. It starts by choosing the database type, then shows relational databases have fixed schemas with tables and rows, using SQL queries and strong ACID consistency. NoSQL databases like DynamoDB have flexible schemas with items that can vary, use API calls for queries, and offer eventual consistency by default. Relational databases scale vertically and are good for complex relationships and transactions, while NoSQL scales horizontally and suits big data and flexible models. Key differences include schema rigidity, query style, consistency guarantees, and scaling methods. Joins are supported in relational but not in NoSQL, which uses denormalization instead. This helps beginners see the practical differences and when to use each type.

Practice

(1/5)
1. Which of the following best describes a key difference between NoSQL databases like DynamoDB and relational databases?
easy
A. NoSQL databases cannot scale horizontally, but relational databases can.
B. NoSQL databases store data without a fixed schema, while relational databases require a fixed schema.
C. Relational databases store data as key-value pairs, while NoSQL uses tables.
D. NoSQL databases always use SQL language, while relational databases do not.

Solution

  1. Step 1: Understand schema requirements

    NoSQL databases like DynamoDB allow flexible, schema-less data storage, meaning you don't have to define all columns upfront.
  2. Step 2: Compare with relational databases

    Relational databases require a fixed schema with tables and columns defined before storing data.
  3. Final Answer:

    NoSQL databases store data without a fixed schema, while relational databases require a fixed schema. -> Option B
  4. Quick Check:

    Schema flexibility = D [OK]
Hint: Remember: NoSQL = flexible schema, relational = fixed schema [OK]
Common Mistakes:
  • Thinking NoSQL always uses SQL language
  • Confusing data storage formats between NoSQL and relational
  • Assuming NoSQL cannot scale horizontally
2. Which of the following is the correct way to describe DynamoDB's data model?
easy
A. DynamoDB stores data in fixed tables with strict column types like SQL databases.
B. DynamoDB requires complex JOIN operations to combine tables.
C. DynamoDB stores data as flexible key-value pairs or documents without fixed columns.
D. DynamoDB uses only relational schemas with foreign keys.

Solution

  1. Step 1: Identify DynamoDB data model

    DynamoDB is a NoSQL database that stores data as flexible key-value pairs or documents, not fixed tables.
  2. Step 2: Eliminate incorrect options

    Options A, B, and D describe relational database features which DynamoDB does not require.
  3. Final Answer:

    DynamoDB stores data as flexible key-value pairs or documents without fixed columns. -> Option C
  4. Quick Check:

    DynamoDB data model = C [OK]
Hint: DynamoDB = flexible key-value or document store, not fixed tables [OK]
Common Mistakes:
  • Thinking DynamoDB uses SQL JOINs
  • Assuming DynamoDB has fixed columns like relational DB
  • Confusing relational schema terms with NoSQL
3. Consider a DynamoDB table storing user profiles with flexible attributes. Which statement is true about querying this data compared to a relational database?
medium
A. DynamoDB queries are optimized for key-value lookups and simple filters, not complex joins.
B. You can perform complex JOIN queries across multiple tables easily in DynamoDB.
C. DynamoDB requires a fixed schema to run queries.
D. Relational databases cannot enforce data integrity rules like DynamoDB.

Solution

  1. Step 1: Understand DynamoDB query capabilities

    DynamoDB is designed for fast key-value lookups and simple filtering, but does not support complex JOIN operations like relational databases.
  2. Step 2: Compare with relational databases

    Relational databases support complex JOINs and enforce data integrity rules, unlike DynamoDB.
  3. Final Answer:

    DynamoDB queries are optimized for key-value lookups and simple filters, not complex joins. -> Option A
  4. Quick Check:

    Query complexity = B [OK]
Hint: DynamoDB = simple filters, no complex JOINs [OK]
Common Mistakes:
  • Assuming DynamoDB supports SQL JOINs
  • Thinking DynamoDB requires fixed schema for queries
  • Believing relational DBs lack data integrity
4. You wrote a DynamoDB query to retrieve items by a non-key attribute but it returns no results. What is the most likely cause?
medium
A. The table schema is fixed and missing the attribute.
B. The query syntax is invalid because DynamoDB uses SQL JOINs.
C. DynamoDB requires all attributes to be indexed automatically.
D. DynamoDB only allows queries on primary key attributes, not on arbitrary columns.

Solution

  1. Step 1: Recall DynamoDB query restrictions

    DynamoDB queries work only on primary key attributes or indexed attributes, not on arbitrary non-key attributes.
  2. Step 2: Analyze other options

    The query syntax is invalid because DynamoDB uses SQL JOINs. is wrong because DynamoDB does not use SQL JOINs. DynamoDB requires all attributes to be indexed automatically. is incorrect as indexes must be created explicitly. The table schema is fixed and missing the attribute. is invalid because DynamoDB is schema-less.
  3. Final Answer:

    DynamoDB only allows queries on primary key attributes, not on arbitrary columns. -> Option D
  4. Quick Check:

    Query keys only = A [OK]
Hint: Query only on keys or indexes in DynamoDB [OK]
Common Mistakes:
  • Trying to query non-key attributes without indexes
  • Expecting SQL JOIN support in DynamoDB
  • Assuming DynamoDB has fixed schema
5. You need to design a system that stores user data with varying attributes and must scale easily with traffic. Which database choice and design is best?
hard
A. Use DynamoDB with flexible schema and partition keys to scale horizontally.
B. Use a relational database with fixed tables and complex JOINs for all queries.
C. Use a relational database but avoid indexes to improve speed.
D. Use DynamoDB but enforce a strict fixed schema for all items.

Solution

  1. Step 1: Analyze requirements for flexibility and scalability

    The system needs to handle varying user attributes and scale easily with traffic.
  2. Step 2: Match database features to requirements

    DynamoDB offers flexible schema and horizontal scaling using partition keys, making it suitable. Relational DBs with fixed schema and complex JOINs are less flexible and harder to scale horizontally.
  3. Final Answer:

    Use DynamoDB with flexible schema and partition keys to scale horizontally. -> Option A
  4. Quick Check:

    Flexible schema + scalability = A [OK]
Hint: Flexible schema + partition keys = DynamoDB scaling [OK]
Common Mistakes:
  • Choosing relational DB for flexible schema needs
  • Avoiding indexes in relational DB reduces performance
  • Forcing fixed schema in DynamoDB defeats flexibility