DEA-C01 Data Store Management Practice Question
A company has a DynamoDB table with a partition key of 'user_id' and a sort key of 'timestamp'. They need to query all items for a user within a date range. Which query operation should be used?
⚠ Common exam trap
Candidates often confuse BatchGetItem with Query, thinking BatchGetItem can handle range queries, but BatchGetItem only retrieves items by exact primary key values and cannot filter by sort key conditions.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
Query with KeyConditionExpression on partition key and sort key
The Query operation in DynamoDB is designed to retrieve items based on a specific partition key and an optional sort key condition. Since the table has a partition key of 'user_id' and a sort key of 'timestamp', using Query with a KeyConditionExpression that filters on the partition key (user_id) and a range condition on the sort key (timestamp) is the most efficient and correct approach to get all items for a user within a date range.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
BatchGetItem with multiple keys
Why it's wrong here
BatchGetItem fetches multiple items by full primary keys and cannot express a sort-key range condition, so it returns only the exact items listed. It is tempting for retrieving several known items in one call, which is its actual purpose, but not for range queries.
- ✓
Query with KeyConditionExpression on partition key and sort key
Why this is correct
A Query operation targets a single partition key value and can filter the sort key with a range condition, so KeyConditionExpression on both keys returns exactly the user's items within the date range. Scan cannot filter on the sort key efficiently and reads the whole table.
- ✗
GetItem with both partition and sort key
Why it's wrong here
GetItem retrieves a single item by its complete primary key, so it cannot return the multiple items spanning a timestamp range. It is tempting because it uses both key attributes, but it is the correct choice only when exactly one item, identified by partition and sort key, is required.
- ✗
Scan with FilterExpression
Why it's wrong here
Scan reads every item in the table and applies FilterExpression afterwards, so it cannot efficiently retrieve one user's date-range items using the sort key. It is tempting when query flexibility is needed across non-key attributes, but that is the scenario where no usable key condition exists.
Go deeper
Related to this question
About these practice questions
One of 1,321 original DEA-C01 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →
JA
Written by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
This DEA-C01 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DEA-C01 exam.