Q31 — AWS DVA-C02 Ch.3
Question 31 of 100 | ← Chapter 3
A company has an e-commerce application. To track product reviews, the company’s development team uses an Amazon DynamoDB table. Each record includes the following attributes: Review ID—a 16-digit universally unique identifier (UUID); Product ID and User ID—16-digit UUIDs referencing other tables; Product Rating—a numeric rating from 1 to 5; and an optional review comment. The partition key of the table is Review ID. The most frequently executed query is retrieving the top 10 reviews with the highest ratings for a given product. Which index will provide the fastest response for this query?
- A. A Global Secondary Index (GSI) with Product ID as the partition key and Product Rating as the sort key. ✓
- B. A Global Secondary Index (GSI) with Product ID as the partition key and Review ID as the sort key.
- C. A Local Secondary Index (LSI) with Product ID as the partition key and Product Rating as the sort key.
- D. A Local Secondary Index (LSI) with Review ID as the partition key and Product ID as the sort key.
Correct Answer: A. A Global Secondary Index (GSI) with Product ID as the partition key and Product Rating as the sort key.
Explanation
Option A proposes a Global Secondary Index (GSI) with Product ID as the partition key and Product Rating as the sort key. This allows efficient querying for the top 10 highest-rated reviews for a given product, since the GSI partitions by Product ID and sorts by Product Rating in descending order (enabling efficient Top-N queries). Other options present issues: Option B uses Review ID as the sort key, which is unsuitable for rating-based ranking. Option C attempts an LSI with Product Rating as the sort key—but LSIs require the same partition key as the base table (Review ID), making Product ID an invalid partition key for an LSI. Option D also violates LSI constraints by using Review ID as the partition key and Product ID as the sort key, which does not support the required query pattern. Thus, Option A is optimal. 【Lantern Certification provided by: swufelp1999】