Question 1,298 of 724
DVA-C02 Development with AWS Services Practice Question
A developer is creating a new DynamoDB table to store order data. The orders have a unique order ID and are retrieved by order ID. Occasionally, the developer needs to query orders by customer ID. Which design approach would minimize costs and provide the fastest queries?
⚠ Common exam trap
Many candidates choose Option B (customer ID as partition key) thinking it naturally supports both access patterns, but they overlook the hot partition problem and the fact that retrieving a single order by order ID would require a scan or a query with a known customer ID, which is not always available.
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
✓
Use the order ID as the partition key and create a global secondary index on customer ID
Using the order ID as the partition key ensures the most efficient primary key access for the primary query pattern (retrieving by order ID). Creating a Global Secondary Index (GSI) on customer ID allows efficient querying by customer ID without scanning the base table, and GSIs have separate read/write capacity from the base table, so you only pay for the index when it is used. This design minimizes costs by avoiding unnecessary scans and provides the fastest queries for both access patterns.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Use the order ID as the partition key and create a global secondary index on customer ID
Why this is correct
This design effectively supports two distinct access patterns: retrieving a specific order by its unique order ID using a highly efficient GetItem operation, and querying all orders associated with a particular customer ID. By establishing a Global Secondary Index (GSI) with customer ID as its partition key, DynamoDB can efficiently retrieve all items matching that customer, optimizing performance and minimizing read capacity unit consumption for both primary and secondary query types.
- ✗
Use the customer ID as the partition key and order ID as the sort key
Why it's wrong here
Using customer ID as the partition key and order ID as the sort key would create a composite primary key. While this allows efficient retrieval of all orders for a specific customer, or a specific order for a specific customer, it makes retrieving an order solely by its order ID highly inefficient. Without knowing the customer ID, DynamoDB cannot directly locate the item, forcing a full table Scan or an exhaustive Query across all customer partitions, which is not scalable.
- ✗
Use the order ID as the partition key and scan the table for customer ID queries
Why it's wrong here
While order ID as the partition key enables very fast lookups for individual orders, relying on a Scan operation to find orders by customer ID is fundamentally flawed for anything beyond trivial datasets. A Scan reads every single item in the table, consuming significant read capacity units (RCUs), incurring high costs, and resulting in unacceptable latency as the table grows. This approach is not suitable for any regular or even occasional query pattern involving customer ID.
- ✗
Use the customer ID as the partition key and create a local secondary index on order ID
Why it's wrong here
A Local Secondary Index (LSI) shares the same partition key as its base table, meaning it can only provide an alternate sort key for items within the same partition. Therefore, even with an LSI on order ID, you would still need to provide the customer ID (the base table's partition key) to query the LSI. Retrieving an order solely by order ID without knowing the customer ID would still necessitate a full table Scan or an inefficient Query across all partitions, as the LSI cannot be queried independently.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Last reviewed: Jun 11, 2026
This DVA-C02 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 DVA-C02 exam.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.