AWS Certified Developer – Associate (DVA-C02) — Question 542
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?
Answer options
- A. Configure the partition key to use the customer email address as the sort key.
- B. Update the table to use the customer email address as the partition key.
- C. Create a local secondary index (LSI) with the customer email address as the sort key.
- D. Create a global secondary index (GSI) with the customer email address as the partition key.
Correct answer: D
Explanation
Creating a global secondary index (GSI) allows the developer to query the table using a different partition key (the customer email address) than the base table's partition key (order ID). A local secondary index (LSI) would not work because it requires the same partition key as the base table. Furthermore, GSIs can be created after table creation, providing the flexibility to add more indexes for other attributes in the future.