Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is a partition key in DynamoDB?
A partition key is the primary attribute used to distribute data across partitions in DynamoDB. It determines where the data is stored and how it is accessed.
Click to reveal answer
beginner
Why is choosing a good partition key important?
A good partition key ensures even data distribution and avoids 'hot partitions' that can slow down performance. It helps DynamoDB scale efficiently.
Click to reveal answer
intermediate
What happens if a partition key has low cardinality?
Low cardinality means few unique values for the partition key. This causes uneven data distribution and can create hot partitions, leading to slower queries.
Click to reveal answer
intermediate
How can you choose a partition key to avoid hot partitions?
Pick a key with many unique values that are accessed evenly. For example, use user IDs or order IDs instead of a fixed status or category.
Click to reveal answer
beginner
What is a composite primary key in DynamoDB?
A composite primary key uses both a partition key and a sort key. This allows multiple items to share the same partition key but be uniquely identified by the sort key.
Click to reveal answer
What does the partition key in DynamoDB determine?
AThe number of tables
BThe size of the database
CWhere data is stored and how it is accessed
DThe encryption method
✗ Incorrect
The partition key determines the physical location of data and how DynamoDB accesses it.
Which is a sign of a poor partition key choice?
AMany unique values
BLow cardinality causing hot partitions
CEven data distribution
DUsing user IDs
✗ Incorrect
Low cardinality means few unique values, causing uneven data distribution and hot partitions.
What is a composite primary key made of?
APartition key and sort key
BTwo partition keys
CSort key only
DPartition key and timestamp
✗ Incorrect
A composite primary key combines a partition key and a sort key to uniquely identify items.
Which attribute is best for a partition key?
AUser ID with many unique values
BFixed category name
CStatus with values like 'open' or 'closed'
DBoolean flag
✗ Incorrect
User ID usually has many unique values, helping distribute data evenly.
What problem do hot partitions cause?
AAutomatic backups
BFaster queries
CMore storage space
DSlower performance and throttling
✗ Incorrect
Hot partitions cause slower performance because too many requests target the same partition.
Explain why selecting a good partition key is important in DynamoDB.
Think about how data is stored and accessed.
You got /4 concepts.
Describe what a composite primary key is and when you might use it.
Consider how to store related items together.
You got /4 concepts.
Practice
(1/5)
1. What is the main role of a partition key in DynamoDB?
easy
A. It sets the maximum size of the table.
B. It defines the data type of the table.
C. It determines how data is distributed across storage nodes.
D. It controls the read and write capacity of the table.
Solution
Step 1: Understand partition key purpose
The partition key is used to decide where data is stored in DynamoDB's distributed system.
Step 2: Compare options
Only It determines how data is distributed across storage nodes. correctly describes this role; others describe unrelated features.
Final Answer:
It determines how data is distributed across storage nodes. -> Option C
Quick Check:
Partition key = data distribution [OK]
Hint: Partition key decides data location in storage [OK]
Common Mistakes:
Confusing partition key with capacity settings
Thinking partition key sets data type
Assuming partition key limits table size
2. Which of the following is a valid way to define a partition key in a DynamoDB table creation command?
easy
A. "KeySchema": [{"AttributeName": "UserId", "KeyType": "HASH"}]
B. "KeySchema": [{"AttributeName": "UserId", "KeyType": "RANGE"}]
C. "KeySchema": [{"AttributeName": "UserId", "KeyType": "PRIMARY"}]
D. "KeySchema": [{"AttributeName": "UserId", "KeyType": "INDEX"}]
Solution
Step 1: Recall partition key syntax
Partition key uses KeyType "HASH" in DynamoDB KeySchema.
Step 2: Check each option
Only "KeySchema": [{"AttributeName": "UserId", "KeyType": "HASH"}] uses "HASH" correctly; others use invalid or incorrect KeyType values.
Final Answer:
"KeySchema": [{"AttributeName": "UserId", "KeyType": "HASH"}] -> Option A
Quick Check:
Partition key = KeyType HASH [OK]
Hint: Partition key uses KeyType 'HASH' in schema [OK]
Common Mistakes:
Using RANGE instead of HASH for partition key
Confusing PRIMARY or INDEX as KeyType
Misnaming KeyType values
3. Given a DynamoDB table with partition key UserId having many unique values, and sort key OrderDate, what will happen if you query with UserId = '123' only?
medium
A. The query will fail because sort key is missing.
B. You get all orders for user '123' sorted by OrderDate.
C. You get only one order for user '123' without sorting.
D. You get all orders for all users sorted by OrderDate.
Solution
Step 1: Understand query with partition key only
Querying with partition key returns all items with that key, optionally sorted by sort key.
Step 2: Analyze given keys
Since UserId is partition key and OrderDate is sort key, querying UserId='123' returns all orders for that user sorted by OrderDate.
Final Answer:
You get all orders for user '123' sorted by OrderDate. -> Option B
Quick Check:
Query by partition key returns all matching items [OK]
Hint: Query by partition key returns all matching items [OK]
Common Mistakes:
Thinking query needs sort key value
Expecting only one item without sort key
Assuming query returns all users' data
4. You designed a DynamoDB table with CustomerId as partition key but notice hot partitions causing slow performance. What is the likely cause?
medium
A. CustomerId has too many unique values causing large partitions.
B. CustomerId is used as sort key instead of partition key.
C. CustomerId is missing from the KeySchema.
D. CustomerId has very few unique values causing uneven data distribution.
Solution
Step 1: Understand hot partitions
Hot partitions happen when few partition keys get most traffic, causing uneven load.
Step 2: Analyze CustomerId uniqueness
If CustomerId has few unique values, many requests hit same partitions causing hot spots.
Final Answer:
CustomerId has very few unique values causing uneven data distribution. -> Option D
Quick Check:
Few unique keys = hot partitions [OK]
Hint: Few unique partition keys cause hot partitions [OK]
Common Mistakes:
Assuming too many unique keys cause hot partitions
Confusing missing key with performance issue
Mixing partition key with sort key roles
5. You want to design a DynamoDB table to store IoT sensor data from thousands of devices. Which partition key choice will best support even data distribution and scalability?
hard
A. Use DeviceId as partition key because it has many unique values.
B. Use a constant string like 'SensorData' as partition key for all items.
C. Use Timestamp as partition key to sort data by time.
D. Use DeviceType as partition key since it groups similar devices.
Solution
Step 1: Identify key with many unique values
DeviceId uniquely identifies each device, providing many distinct partition keys.
Step 2: Evaluate other options
Constant string causes hot partition; Timestamp changes too fast for partition key; DeviceType groups few devices causing uneven load.
Final Answer:
Use DeviceId as partition key because it has many unique values. -> Option A
Quick Check:
Many unique keys = good partition key [OK]
Hint: Choose partition key with many unique values [OK]