Q3. What are the two types of primary key in DynamoDB?
A simple primary key is just a partition key (also called a hash key). A composite primary key is a partition key plus a sort key (also called a range key).
With a simple key, each item is found by one value. With a composite key, many items can share a partition key and are stored together, sorted by the sort key, which is what makes range queries within a partition efficient.
// Simple key: one partition key
{ "userId": "u#42" }
// Composite key: partition key + sort key
{ "userId": "u#42", "orderId": "2026-07-04#001" }