Topic lessonTopic: DynamoDB key design and workload skew
Design DynamoDB keys around access patterns|Compare with SQL Server
Reading an order by ID and listing one customer's orders by date are distinct access patterns. Translate both into key, index and write-cost decisions.
Translate both into key, index and write-cost decisions.
This exercise uses fictional evidence and makes no changes in a live environment.
Start with the requests
Choose the primary read paths and workload distribution first. A sort key supports ranges within a partition key value.
- Demand → PrimaryDefine the use
- Primary → SecondaryDesign the layout
- Secondary → VerifyVerify equivalent results
- Demand
- Order ID or customer and dates
- Primary
- Look up the order ID
- Secondary
- Query customer and date
- Verify
- Check results and skew
Compare three synthetic use cases
| Use | Candidate | Check |
|---|---|---|
| Show one order | Unique order ID | Return the same synthetic order |
| Customer history | Customer and date index | Exercise date bounds and ties |
| All-customer reporting | Separate analytical path | Match period and row count |
| Peak period | Include a dominant customer | Measure the index separately |
Flexible SQL Server reports may need an analytical path distinct from operational reads.
Evidence for the decision
Describe each read Record the key, expected result size and distribution requirement.
Check the secondary path Compare index write impact, consistency requirements and charges.
Reevaluate assumptions Review the layout when frequency, writes or analytical needs change.
Check your decision
Choose an option to see the result and explanation.
Check, then explain in your own words
- List business reads.
- Compare primary and secondary paths.
- Verify output and load.
Check your understanding: Does copying the SQL Server schema preserve the query experience?
Test the required reads, ordering, consistency and distribution.
The best key depends on access patterns.
Sources and conditions checked
The official references used in this lesson are collected here with their scope, conditions and corresponding sections. Independent expert review and live AWS comparison have not been performed.
Scope and conditionsPartition keys and workload distribution.
Used in this lessonStart with the requests Compare three synthetic use cases Evidence for the decision