What is the difference between Amazon RDS and DynamoDB?
Compare Amazon RDS and DynamoDB: relational SQL vs NoSQL, transactions vs key-value access, and how to choose the right AWS database for your workload.
Expected Interview Answer
Amazon RDS is a managed relational (SQL) database service for structured data with joins and transactions, while DynamoDB is a fully managed NoSQL key-value and document database built for massive scale and single-digit-millisecond latency.
RDS runs engines like PostgreSQL, MySQL, or SQL Server on provisioned instances, uses a fixed schema, and is ideal for complex queries, joins, and ACID transactions. DynamoDB is serverless, schemaless beyond its key structure, scales horizontally without capacity planning, and is accessed by partition and sort keys rather than arbitrary SQL. Choose RDS for relational integrity and complex reporting; choose DynamoDB for predictable-latency, high-throughput access patterns known in advance.
- RDS provides SQL, joins, and ACID transactions
- DynamoDB delivers consistent low latency at any scale
- DynamoDB is serverless with no instances to manage
- RDS suits complex, ad-hoc queries and reporting
- DynamoDB scales horizontally without downtime
AI Mentor Explanation
RDS is like a full official scorebook where every column is defined and you can cross-reference batting, bowling, and fielding in one structured ledger. DynamoDB is like a fast scoreboard operator who instantly shows any player's total by jersey number but can't run complex cross-tabulations. You pick the ledger for analysis and the scoreboard for instant lookups.
Step-by-Step Explanation
Step 1
Classify the data model
Decide whether your data is relational with joins (RDS) or accessed by known keys (DynamoDB).
Step 2
Assess query needs
Choose RDS for ad-hoc SQL and complex reporting; DynamoDB when access patterns are known in advance.
Step 3
Consider scale and latency
Pick DynamoDB for horizontal scale and single-digit-millisecond latency; RDS for moderate, vertically scaled workloads.
Step 4
Evaluate operations
DynamoDB is serverless with no instance patching; RDS manages instances, backups, and read replicas for you.
Step 5
Design keys or schema
For DynamoDB, model partition and sort keys around access patterns; for RDS, define normalized tables and indexes.
What Interviewer Expects
- Clear distinction between relational and NoSQL models
- Understanding of ACID transactions versus key-value access
- Knowledge of DynamoDB partition and sort keys
- Awareness of scaling models (vertical vs horizontal)
- Ability to choose the right service for an access pattern
Common Mistakes
- Assuming DynamoDB supports arbitrary SQL joins
- Choosing DynamoDB without knowing access patterns first
- Believing RDS scales horizontally like DynamoDB
- Ignoring DynamoDB partition key design and hot partitions
- Thinking one service always replaces the other
Best Answer (HR Friendly)
“Amazon RDS is a managed traditional SQL database good for structured data and complex queries, while DynamoDB is a NoSQL database built for huge scale and very fast, predictable lookups. You pick RDS when you need joins and transactions, and DynamoDB when you need speed and scale for known access patterns.”
Code Example
# Managed relational database (RDS)
aws rds create-db-instance \
--db-instance-identifier app-db \
--db-instance-class db.t3.micro \
--engine postgres \
--allocated-storage 20 \
--master-username admin \
--master-user-password 'ChangeMe123!'
# Serverless NoSQL table (DynamoDB)
aws dynamodb create-table \
--table-name Orders \
--attribute-definitions AttributeName=OrderId,AttributeType=S \
--key-schema AttributeName=OrderId,KeyType=HASH \
--billing-mode PAY_PER_REQUESTFollow-up Questions
- How do you design a DynamoDB partition key to avoid hot partitions?
- When would you use DynamoDB Global Secondary Indexes?
- How do RDS read replicas differ from Multi-AZ deployments?
- What is DynamoDB's eventual vs strongly consistent read model?
- When might Amazon Aurora be a better fit than either?
MCQ Practice
1. Which statement about DynamoDB is correct?
DynamoDB is a serverless NoSQL key-value and document store accessed via keys, not SQL joins.
2. For complex ad-hoc SQL queries with joins, which is the better fit?
RDS runs relational engines that support joins, transactions, and ad-hoc SQL.
3. How does DynamoDB primarily scale?
DynamoDB scales horizontally by distributing data across partitions based on the partition key.
Flash Cards
Is RDS SQL or NoSQL? — SQL (relational) — engines like PostgreSQL, MySQL, SQL Server.
How is data accessed in DynamoDB? — By partition key (and optional sort key), not arbitrary SQL joins.
Which service is serverless? — DynamoDB — no instances to provision or patch.
When choose RDS over DynamoDB? — When you need joins, transactions, and complex ad-hoc queries.