Table Design Interview Questions
Table Design interview questions for DynamoDB — fundamentals through advanced scenarios.
- 20Questions with answers
- 3Difficulty levels
Questions (20)
Browse beginner, intermediate, and advanced questions with answers — hide them when you want to self-test.
What should you list before you create a DynamoDB table?
Access patterns come first: every user-facing read and write, the key you will Query on, and expected QPS. DynamoDB has no cheap joins, so a schema that looks tidy in 3NF often forces Scans or extra round-trips. Interviewers want that list, not an ER diagram copied from Postgres.
How do you model a one-to-many relationship without SQL joins?
Store child items in the same partition as the parent, using a sort key that identifies the child (ORDER#<id>, MESSAGE#<ts>). A Query with begins_with returns the collection in one call. Putting children in a separate table is fine only when you never need them in the same request path.
When is duplicating an attribute across DynamoDB items acceptable?
Duplicate fields you must read without a second Query—display names, status labels, or a denormalized total. You pay with extra writes when the source of truth changes, so copy only stable or carefully updated values. Never duplicate large blobs just to make a row look like a SQL join result.
What is single-table design, and when is the complexity justified?
Several entity types share one table with overloaded PK/SK values so related items can be fetched together. It pays off when access patterns are known and the team can own generic keys and GSIs. Multiple tables stay clearer when bounded contexts, IAM, or backup cadences differ.
How do different entity types coexist in one DynamoDB table?
A type prefix on the sort key (USER#, ORDER#, PAYMENT#) plus an attribute such as entityType lets Query and Filters tell items apart. GSIs can project only the types they need. Without prefixes, mixed entities collide on keys and FilterExpressions turn into hidden Scans.
Why is a catch-all table that answers every request with Scan a design smell?
Scan cost and latency grow with table size, and filters still read every item. User-facing paths should be Query by partition key. If you cannot name the key for a request, the table is not designed yet—add a GSI or a new item shape rather than scanning.
What are generic PK and SK attributes used for in table design?
Names like PK and SK let one table hold many entity types without a column per relationship. Application code writes typed values (TENANT#42, ORDER#1001) into those two attributes. The physical table stays simple; the meaning lives in the key conventions you document.
How do you add a new access pattern after the table is already in production?
Prefer a new GSI or a new item type that you dual-write, then backfill. Changing the primary key of existing items is a migration, not an ALTER COLUMN. Feature-flag the new Query path and keep the old one until the backfill and lag checks pass.
How should you version item attributes in a live DynamoDB table?
Add a schemaVersion field and make readers tolerant of missing new attributes. Writers can roll forward per item on the next Update. Avoid rewriting the whole table in one job unless you have a measured backfill window and a rollback that does not strand mixed versions.
When should a growing item be split into multiple DynamoDB items?
Split when you approach the 400 KB limit, when one huge document makes every read expensive, or when different fields change at different rates. Keep a stub item for the identity and child items for history or large collections. Splitting only “for purity” adds round-trips with no gain.
How do GSIs belong in the table-design conversation rather than as a later patch?
Each required Query that the primary key cannot serve should be a named GSI with its own PK/SK and projection. Designing GSIs last often means duplicating the whole item (ALL) and overpaying writes. Sparse and overloaded GSIs are table-design tools, not indexing afterthoughts.
What is a materialized aggregate item and when do you maintain one?
A dedicated item holds a counter or summary you cannot afford to compute with a wide Query on every read—unread count, order total, leaderboard score. Update it in the same transaction or with a disciplined single-item add. Stale aggregates need a rebuild path when the counter drifts.
How do you keep related entities in one partition without creating a hot key?
Colocate only what is queried together and is not a celebrity entity. A global product or tenant-root partition that every request touches will throttle even if the model looks elegant. Spread write-heavy children by a higher-cardinality key and Query them on a GSI when needed.
How would you represent many-to-many relationships in DynamoDB?
Use two item types or an adjacency-list edge item (USER#id / COURSE#id and the inverse) so each side can Query its links. Avoid arrays of IDs that grow past item size. Edge items can carry payload such as enrolledAt without joining a third table.
How would you design a multi-tenant SaaS table so noisy tenants cannot starve others?
Put tenantId into every partition key so isolation is physical, not a filter. Cap per-tenant write rates in the app and watch Contributor Insights for hot tenant keys. Shared partitions that mix all tenants make one customer’s burst everyone else’s incident.
What migration pattern moves a relational module onto DynamoDB without dual-writes forever?
Expand/contract: dual-write both stores, backfill historical rows, shadow-read DynamoDB, then cut reads and stop SQL writes. Keep a reversible flag and compare item counts and checksums. A big-bang dump-and-switch usually misses in-flight orders and unique-key assumptions SQL was enforcing.
How do you bound item-collection size so Query latency stays stable as data grows?
Archive old sort-key ranges to another table or S3, use TTL on event items, or roll time windows into new partitions (userId#2026-09). Unbounded collections under one PK make every “list recent” Query more expensive over years. Design the rollover before the first million items land.
What goes wrong when denormalized copies of the same fact drift?
Readers see contradictory names, prices, or statuses depending on which item they hit. Mitigate with a single writer path, transactions when two items must stay aligned, or treating one item as source of truth and others as caches with TTL. Drift is a design bug, not an eventual-consistency footnote.
How do you serve OLTP lookups and occasional analytics without scanning the live table?
Keep the operational table Query-shaped, then export to S3/Athena or stream changes to a warehouse. Parallel Scan on production for dashboards steals capacity from users. If a product metric must be real-time, maintain a small aggregate item rather than scanning orders.
Which table-design checks would you require before a production launch?
Named access patterns with sample keys, predicted QPS per key, item size budget, GSI list with projections, failure modes for hot keys, backup/PITR, and a load test that hits realistic key cardinality. Shipping “we will add indexes later” is how first-week throttling incidents start.
Practice with AI mock interviews
Run DynamoDB mock interviews with AI follow-ups, instant feedback, and analytics on AiLx.
Free to start · No credit card required