A developer is building a retail application that stores customer order histories in an Amazon DynamoDB table. The base table uses `OrderID` as the partition key. The application needs to support the following two query patterns efficiently:
- Retrieve all orders placed by a specific customer (`CustomerID`) sorted by the order date (`OrderDate`).
- Retrieve all orders that are currently in a `PENDING` status to process them in batches.
Which two database design strategies should the developer implement to meet these requirements with minimal latency and capacity consumption? (Select TWO.)
- Create a Global Secondary Index (GSI) with `CustomerID` as the partition key and `OrderDate` as the sort key.Cevap
- Create a Global Secondary Index (GSI) with `OrderStatus` as the partition key and `OrderID` or `OrderDate` as the sort key.Cevap
- CUse the `Scan` API operation with a `FilterExpression` on `CustomerID` to retrieve and filter the customer's orders.
- DCreate a Local Secondary Index (LSI) with `CustomerID` as the partition key and `OrderDate` as the sort key.
- EIncrease the provisioned read capacity units (RCUs) on the base table to sustain high-throughput scans for orders in the `PENDING` status.
Cevap
Create a Global Secondary Index (GSI) with CustomerID as the partition key and OrderDate as the sort key, and create a Global Secondary Index (GSI) with OrderStatus as the partition key and OrderDate as the sort key.
The correct strategies are to create two Global Secondary Indexes (GSIs). The first GSI uses CustomerID as the partition key and OrderDate as the sort key, enabling efficient Query operations for a specific customer's orders sorted by date. The second GSI uses OrderStatus as the partition key and OrderDate as the sort key, allowing the application to query only the PENDING orders directly instead of scanning the entire table.
Adım Adım Çözüm
Anahtar Kavram
Using Global Secondary Indexes (GSIs) to optimize read performance and support multiple query patterns without scanning the base table.
Tahmini Süre:2m 0s