Why and what
DynamoDB stores items in tables and retrieves them efficiently by keys. A partition key distributes data; an optional sort key orders related items within a partition. It is not a drop-in replacement for arbitrary SQL joins. Start with access patterns: “get a post by ID” and “get a user's recent posts” are different key/index requirements.
Console lab
- Create a lab table
academy-postswith partition keyuser_id(String) and sort keypost_id(String). Choose an appropriate capacity mode and review cost. - Add items such as
user_id=USER#1,post_id=2026-09-01T10:00:00Z#001, caption and status attributes. - Query items for USER#1 and order by the sort key. Compare this with a Scan of the whole table.
- Add another user and show that a Query requires a partition-key value.
- Discuss an index for a separate access pattern such as published posts by category; avoid a single overloaded hot partition at scale.
CLI item example
aws dynamodb put-item --table-name academy-posts \
--item '{"user_id":{"S":"USER#1"},"post_id":{"S":"POST#001"},"caption":{"S":"My first cloud lab"}}' \
--condition-expression 'attribute_not_exists(user_id)'The condition is evaluated against the item at the complete key. It prevents overwriting an existing matching item. SDK document clients can hide low-level type wrappers; do not mix document syntax and low-level API syntax blindly.
Consistency and concurrency
Read consistency choices affect behaviour and cost. Global secondary indexes have their own consistency limitations. Conditional expressions support optimistic concurrency; transactions support grouped operations within documented limits. TTL expiry is asynchronous cleanup, not a precise authorization timer. Enforce expiry in the application when it affects access.
Troubleshooting
A hot key can throttle even if aggregate capacity seems sufficient. Scan is not an efficient substitute for an index. Retry throttled operations with bounded exponential backoff; do not immediately loop forever. Observe consumed capacity and request metrics.
Assignment
Model users, posts and likes with explicit read/write patterns. Explain which operations use a key query, which need an index and which you deliberately do not support. Delete the disposable table after exporting any test data you want to retain.
Official reference
Ravindra’s Tip
पहले पूछो data कैसे पढ़ेंगे, फिर key बनाओ। हर query के लिए Scan चलाना SQL की आदत यहाँ महँगी पड़ सकती है।
Interview and revision check
Why is access-pattern design important before table creation?
Partition/sort keys and indexes determine efficient queries. Arbitrary later queries can otherwise require expensive scans or redesign.
Ravindra Bagale · Cloud & DevOps Academy · Handbook and project downloads