DVA-C02 · Question #451
DVA-C02 Question #451: Real Exam Question with Answer & Explanation
The correct answer is D: Create a global secondary index (GSI) with the customer email address as the partition key.. A DynamoDB Global Secondary Index (GSI) with customer email as the partition key enables querying all orders for a given email and supports future attribute-based queries.
Question
A company has an ecommerce platform. A developer is designing an Amazon DynamoDB table to store customer order data for the platform. The table uses the order ID as the partition key. The developer needs to modify the table to get all order IDs that are associated with a given customer email address in a single query. The solution must give the developer the ability to query order IDs by other item attributes in the future. Which solution will meet these requirements?
Options
- AConfigure the partition key to use the customer email address as the sort key.
- BUpdate the table to use the customer email address as the partition key.
- CCreate a local secondary index (LSI) with the customer email address as the sort key.
- DCreate a global secondary index (GSI) with the customer email address as the partition key.
Explanation
A DynamoDB Global Secondary Index (GSI) with customer email as the partition key enables querying all orders for a given email and supports future attribute-based queries.
Common mistakes.
- A. A partition key cannot simultaneously be the order ID and the customer email; the sort key alone cannot be used as the leading condition in a Query without specifying the partition key.
- B. Changing the partition key to customer email would break all existing queries that look up orders by order ID, which is the primary access pattern.
- C. A Local Secondary Index (LSI) shares the same partition key as the base table (order ID), so it cannot enable queries that start from a customer email address.
Concept tested. DynamoDB Global Secondary Index for alternate query access patterns
Reference. https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html
Community Discussion
No community discussion yet for this question.