[{"id":"dynamodbintermediate-001","courseId":"dynamodb-intermediate","domain":"data-modeling","topic":"High-cardinality partition keys","prompt":"A team is building a table of shipments that will hold millions of items. Which partition key gives the most even write load across partitions?","hint":"Count how many distinct values the key can take, and how evenly requests fall across them.","explain":"The partition key picks where each item lives, so requests spread only across as many key values as the workload uses. Few values, or one dominant value, leaves most partitions idle.","source":"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-partition-key-uniform-load.html","interaction":{"type":"single"},"options":[{"id":"a","text":"Shipment ID, unique for each shipment","why":"Each shipment has its own key value, so writes spread across many partitions."},{"id":"b","text":"Shipment status, such as pending or delivered","whyNot":"Only a few status values exist, so writes pile onto a few partitions."},{"id":"c","text":"Ship date, rounded to the day","whyNot":"All of one day's shipments share a value, so that day's writes hit a single partition."},{"id":"d","text":"Warehouse ID, where one warehouse handles most shipments","whyNot":"One dominant value draws most requests and creates a hot partition."}],"answer":"a","explanation":"Load spreads across partitions in proportion to how many distinct partition key values the workload touches, so high-cardinality keys accessed evenly spread best.","concept":"Load spreads across partitions in proportion to how many distinct partition key values the workload touches, so high-cardinality keys accessed evenly spread best.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Check how many distinct key values exist and how evenly requests hit them before choosing a partition key."]},{"id":"dynamodbintermediate-002","courseId":"dynamodb-intermediate","domain":"data-modeling","topic":"Random write sharding","prompt":"Every write today uses the same partition key value, today's date, so one partition takes the whole load. Which TWO changes spread today's writes across more partition key values?","hint":"Look for a part of the key that varies from item to item.","explain":"Items sharing one partition key value land in the same partition, so one busy value overloads it. A varying part added to the key spreads the load; how you build it decides how later lookups work.","source":"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-partition-key-sharding.html","interaction":{"type":"multiple","tellCount":true},"options":[{"id":"a","text":"Add a random number from 1 to 200 to the end of the date","why":"Random suffixes turn one date value into 200 values, so writes spread over many partitions."},{"id":"b","text":"Add a number calculated from each OrderId to the end of the date","why":"A calculated suffix also spreads writes, and it lets a lookup rebuild the key from the order ID."},{"id":"c","text":"Add the current time to the sort key while the partition key stays the date","whyNot":"The partition key still names one value for the whole day, so writes still land on one partition."},{"id":"d","text":"Store the date as a number instead of a string","whyNot":"The data type of the key does not change how many distinct values exist."},{"id":"e","text":"Keep the bare date key and raise the table's provisioned write capacity","whyNot":"Capacity does not create new partition key values, so the single busy value stays."},{"id":"f","text":"Index the date with a global secondary index","whyNot":"An index does not change which partition key value the base table writes use."}],"answer":"ab","explanation":"Write sharding adds a varying part to the partition key, random or calculated, to spread one hot value; the cost is that reads of that day must query every suffix.","concept":"Write sharding adds a varying part to the partition key, random or calculated, to spread one hot value; the cost is that reads of that day must query every suffix.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["A varying suffix spreads writes, but reading that day's items then means querying each suffix value."]},{"id":"dynamodbintermediate-003","courseId":"dynamodb-intermediate","domain":"data-modeling","topic":"Fan-out reads on sharded keys","prompt":"Your table stores each day's orders under suffixed keys such as 2014-07-09.1 through 2014-07-09.200. One Query on the bare key 2014-07-09 returns every order for that day.","hint":"Check the exact partition key value each item was written under.","explain":"A Query targets one partition key value and returns only what is stored under it. Suffixed writes live under other values, so collecting a whole day can mean several reads merged in the application.","source":"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-partition-key-sharding.html","interaction":{"type":"true-false"},"options":[{"id":"a","text":"True","whyNot":"A Query matches one exact value, and the bare key holds none of the suffixed items."},{"id":"b","text":"False","why":"Each order sits under its own suffixed key, so the application must query every suffix and merge the results."}],"answer":"b","explanation":"A Query reads only the exact partition key value it names, so a suffixed key needs one query per suffix followed by a merge in the application.","concept":"A Query reads only the exact partition key value it names, so a suffixed key needs one query per suffix followed by a merge in the application.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Write-sharded items need one query per suffix; a bare-key query misses them."]},{"id":"dynamodbintermediate-004","courseId":"dynamodb-intermediate","domain":"data-modeling","topic":"Hierarchical composite sort keys","prompt":"Within one partition key value, items use sort keys of the form country#region#city, as the sample values show. Which sort key condition returns every city in Oregon, USA, and nothing else?","hint":"Ask which part of the sort key the condition must match to reach every level under one value.","explain":"A sort key can pack several levels into one string joined by a delimiter. A condition on it selects items by comparing text, so the slice returned depends on which part of the string the condition compares.","source":"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-sort-keys.html","interaction":{"type":"single"},"options":[{"id":"a","text":"begins_with(sk, 'USA#Oregon#')","why":"A prefix condition matches every sort key that starts with that text, so it returns all Oregon cities and no others."},{"id":"b","text":"sk = 'USA#Oregon'","whyNot":"An exact match returns only the item whose sort key is that exact value, not the cities under it."},{"id":"c","text":"begins_with(sk, 'Oregon#')","whyNot":"The prefix must match from the start of the sort key, so skipping the country level matches nothing."},{"id":"d","text":"sk > 'USA#Oregon'","whyNot":"Greater-than runs on past Oregon, so it also returns later values such as USA#Texas."}],"answer":"a","explanation":"A composite sort key packs levels into one string, so a begins_with condition on a leading prefix returns every item under that level in a single query.","concept":"A composite sort key packs levels into one string, so a begins_with condition on a leading prefix returns every item under that level in a single query.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","code":"USA#Oregon#Portland\nUSA#Oregon#Salem\nUSA#Texas#Austin\nCAN#Ontario#Toronto","takeaways":["A composite sort key supports range queries at any level, as long as the prefix starts at the first level."]},{"id":"dynamodbintermediate-005","courseId":"dynamodb-intermediate","domain":"data-modeling","topic":"Version prefixes in sort keys","prompt":"A parts maker stores Equipment_1's audit results as items whose sort keys start with v0_, v1_, v2_ and so on. Which single query returns only the most recent audit status?","hint":"Think about which prefix the design reserves for the copy that changes on every update.","explain":"Sort keys can begin with a version marker, with one marker reserved for the copy rewritten on each change. A prefix query returns every item starting with that text; a point read needs the full key.","source":"https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/bp-sort-keys.html","interaction":{"type":"single"},"options":[{"id":"a","text":"Query Equipment_1 with sort key begins_with v0_","why":"The zero prefix is kept on the copy holding the latest contents, so this prefix returns just that item."},{"id":"b","text":"Query Equipment_1 with sort key begins_with v1_","whyNot":"The v1_ item is the first audit, so this returns the oldest result, not the latest."},{"id":"c","text":"Query Equipment_1 with sort key begins_with v","whyNot":"A broad prefix matches every version, so it returns the whole history instead of the latest status."},{"id":"d","text":"GetItem with partition key Equipment_1 and sort key v0","whyNot":"GetItem needs the full stored sort key, and v0 alone is not one, so nothing is returned."}],"answer":"a","explanation":"A fixed version prefix on the copy rewritten at each update lets a prefix query read the latest status without touching the history.","concept":"A fixed version prefix on the copy rewritten at each update lets a prefix query read the latest status without touching the history.","rev":1,"updatedAt":"2026-10-26","kind":"scenario","takeaways":["Keep one fixed prefix for the latest copy so a prefix query returns it alone."]}]