DynamoDB interview question · Most asked
What is single-table design, and what are its pros and cons?
Summary
Single-table design stores several entity types in one table with generic key attributes (PK, SK, GSI1PK, ...) so related items live in the same item collection and can be fetched together in one Query, effectively pre-joining data.
Longer Answer
Pros: fewer round trips (fetch a customer and their recent orders in one request), fewer tables to provision and monitor, and overloaded GSIs serving several patterns.
Cons: a steeper learning curve, harder ad-hoc inspection and analytics, schema changes and new patterns are harder, and per-entity settings (streams, TTL, backups, capacity) apply to everything in the table.
It is a tool, not a rule. Many teams use one table per bounded context or service, and separate tables when entities have different access, scaling or lifecycle needs. Use single-table design where fetching related entities together really matters.
Key Points
- Several entity types, generic key names.
- Related items in one item collection.
- Fewer round trips; harder analytics and evolution.
- Use where it pays off, not by default.
More most-asked DynamoDB questions
- What are DynamoDB Streams, and how are they used?
- Explain partition keys, sort keys and the two kinds of primary key.
- What is DynamoDB, and what workloads is it a good fit for?
- What is a hot partition, and how do you avoid one?
- How do you approach data modelling in DynamoDB, and how is it different from relational design?
- Global secondary index or local secondary index: what is the difference?
- Query or Scan: what is the difference, and why avoid Scan?
- How do conditional writes work, and how do you implement optimistic locking in DynamoDB?