Senior LevelCloud Computing (AWS/GCP/Azure)
How do you implement Advanced Single-Table Design in Amazon DynamoDB?
❓ Interview Prompt: Explain DynamoDB Single-Table Design (Alex DeBrie pattern), generic PK/SK keys, adjacent item collections, and satisfying access patterns in 1 query.
In relational databases, normalized data is split across multiple tables and joined at query time. In DynamoDB, execute joins is impossible. Single-Table Design models an entire application domain (Users, Orders, Products, Payments) into one single physical DynamoDB table.
Core Single-Table Design Principles:
1
Generic Partition Key ('PK') & Sort Key ('SK'): Attributes are named generically ('PK' and 'SK') to store different entity types in the same columns.
2
Item Collections: Store related entities side-by-side using matching 'PK' values:
•
'PK = "USER#1042"' / 'SK = "METADATA"' (User Profile)
•
'PK = "USER#1042"' / 'SK = "ORDER#2026-01"' (User Order 1)
•
'PK = "USER#1042"' / 'SK = "ORDER#2026-02"' (User Order 2)
3
Single Query Fetch: A single 'QueryCommand' on 'PK = "USER#1042"' fetches the user profile AND all recent orders in a single sub-10ms query!
Code Implementation Example
json
[
{ "PK": "USER#1042", "SK": "METADATA", "Name": "Alice", "Email": "alice@co.com" },
{ "PK": "USER#1042", "SK": "ORDER#9901", "Total": 150.00, "Status": "SHIPPED" },
{ "PK": "USER#1042", "SK": "PAYMENT#4401", "CardLast4": "4242", "Status": "PAID" }
]💡DynamoDB Single-Table Design layout storing User, Order, and Payment items in 1 table.
🎯 Interview Key Takeaway
Single-table design models multiple entities into one physical DynamoDB table using generic PK/SK keys to satisfy all access patterns in 1 query.
#Single-Table Design#DynamoDB#NoSQL#Data Modeling#Senior
Back to all Cloud Computing (AWS/GCP/Azure) Questions→