A DynamoDB table for product orders uses orderId as the partition key only (no sort key). The application needs to support queries by customerId. Which option enables querying the table by customerId?
Choose an answer
Tap an option to check your answer.
Correct answer: Create a global secondary index (GSI) on the table with customerId as the partition key..
Why this is the answer
Creating a global secondary index (GSI) with customerId as the partition key allows you to query the DynamoDB table efficiently using customerId. A GSI is a sparse index that can have a different partition key and sort key from the base table, enabling queries on non-primary key attributes. Altering the table's primary key is not possible after creation; you would need to create a new table and migrate data. A local secondary index (LSI) must share the same partition key as the base table, so it cannot use customerId as its partition key. An LSI that keeps orderId as the partition key and adds customerId as the sort key would only allow queries that start with orderId, not directly by customerId.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed