What Is Amazon DynamoDB and When Should You Use It?
Learn what Amazon DynamoDB is, how its key-value and document model works, provisioned vs on-demand capacity, and when to choose it over a SQL database.
Expected Interview Answer
Amazon DynamoDB is a fully managed, serverless NoSQL key-value and document database that delivers single-digit millisecond performance at virtually any scale, without you provisioning or managing servers.
DynamoDB stores items in tables identified by a partition key (and optionally a sort key), and it automatically partitions data across nodes to handle throughput and storage growth. It offers two capacity modes: provisioned, where you set read/write capacity units, and on-demand, where it scales automatically and you pay per request. Global Secondary Indexes and Local Secondary Indexes let you query on attributes beyond the primary key. DynamoDB Streams capture item-level changes for event-driven processing, and Global Tables replicate data across regions for low-latency multi-region access. It fits access patterns you can predict up front — like retrieving a user profile by ID or an order by order number — better than complex ad hoc joins, which is why data modeling in DynamoDB is designed around known query patterns rather than normalized relational schemas.
- Consistent single-digit millisecond latency at any scale
- Fully managed, serverless — no server provisioning or patching
- On-demand capacity mode scales automatically with traffic
- Global Tables enable low-latency multi-region replication
- DynamoDB Streams enable event-driven architectures on data changes
AI Mentor Explanation
DynamoDB is like a scoreboard system built to instantly return one player's stats the moment you type their jersey number, rather than a full archive room you'd search page by page. It scales from a single school match to a packed international stadium without anyone rebuilding the scoreboard, and it can mirror the same live numbers to giant screens in stadiums on the other side of the world.
Step-by-Step Explanation
Step 1
Model around access patterns first
Design the table's partition key and sort key based on the exact queries the application needs, not a normalized schema.
Step 2
Choose a capacity mode
Provisioned mode sets fixed read/write capacity; on-demand mode scales automatically and bills per request.
Step 3
Add indexes for extra query patterns
Global Secondary Indexes and Local Secondary Indexes support queries beyond the primary key.
Step 4
React to changes with Streams
DynamoDB Streams emit an ordered log of item-level changes that Lambda can process for event-driven workflows.
Step 5
Replicate globally if needed
Global Tables replicate a table across multiple AWS regions for low-latency reads and writes worldwide.
What Interviewer Expects
- Explains DynamoDB as a fully managed, serverless NoSQL key-value/document store
- Describes partition keys, sort keys, and designing around access patterns
- Distinguishes provisioned versus on-demand capacity modes
- Mentions GSIs/LSIs, Streams, and Global Tables as key features
- Knows when DynamoDB fits better than a relational database
Common Mistakes
- Trying to design a DynamoDB schema the same way as a normalized relational schema
- Assuming DynamoDB supports arbitrary ad hoc joins efficiently
- Ignoring hot partition issues from a poorly chosen partition key
- Confusing Global Secondary Indexes with Global Tables
Best Answer (HR Friendly)
“DynamoDB is Amazon's managed NoSQL database that responds extremely fast even at huge scale, and you never have to manage servers for it. It's ideal when you know exactly how you'll look up your data, like fetching a user's profile by their ID.”
Code Example
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { DynamoDBDocumentClient, QueryCommand } from "@aws-sdk/lib-dynamodb";
const client = DynamoDBDocumentClient.from(new DynamoDBClient({}));
const result = await client.send(new QueryCommand({
TableName: "Orders",
KeyConditionExpression: "customerId = :cid",
ExpressionAttributeValues: { ":cid": "CUST-1042" },
}));
console.log(result.Items);Follow-up Questions
- What's the difference between a Global Secondary Index and a Local Secondary Index?
- How does DynamoDB achieve single-digit millisecond latency at scale?
- What is a hot partition and how do you avoid one?
- When would you choose DynamoDB over Amazon RDS?
- How do DynamoDB Streams enable event-driven architectures?
MCQ Practice
1. What type of database is DynamoDB?
DynamoDB is AWS's fully managed, serverless NoSQL key-value and document database.
2. What should primarily drive DynamoDB table design?
DynamoDB schemas are designed around the specific queries the application needs, not normalized relational design.
3. Which DynamoDB feature replicates a table across AWS regions?
Global Tables provide multi-region replication for low-latency global access.
Flash Cards
What is DynamoDB? — A fully managed, serverless NoSQL key-value and document database from AWS.
What should drive DynamoDB table design? — The application's known access patterns, not a normalized relational schema.
What are the two DynamoDB capacity modes? — Provisioned (set read/write units) and on-demand (auto-scales, pay per request).
What do DynamoDB Streams provide? — An ordered, item-level change log usable to trigger event-driven processing, e.g. via Lambda.