Topic 1 Question 363
A developer is creating a web application for a school that stores data in Amazon DynamoDB. The ExamScores table has the following attributes: student_id, subject_name, and top_score.
Each item in the ExamScores table is identified with student_id as the partition key and subject_name as the sort key. The web application needs to display the student _id for the top scores for each school subject. The developer needs to increase the speed of the queries to retrieve the student_id for the top scorer for each school subject.
Which solution will meet these requirements?
Create a local secondary index (LSI) with subject_name as the partition key and top_score as the sort key.
Create a local secondary index (LSI) with top_score as the partition key and student_id as the sort key.
Create a global secondary index (GSI) with subject_name as the partition key and top_score as the sort key.
Create a global secondary index (GSI) with subject_name as the partition key and student_id as the sort key.
ユーザの投票
コメント(2)
- 正解だと思う選択肢: C
GSI - diff part key and sort key | LSI - same part key and diff sort key
👍 3rdiaz2024/07/11 - 正解だと思う選択肢: C
The best solution is C. Create a global secondary index (GSI) with subject_name as the partition key and top_score as the sort key.
Here's why: The goal is to efficiently retrieve the student ID of the top scorer for each subject. A GSI allows querying on a key combination different from the table's primary key. By using subject_name as the partition key, you can easily query all scores for a given subject. Then, sorting by top_score in descending order will allow you to quickly identify the top scorer using a single query. An LSI (options A and B) is tied to the table's primary key, making efficient retrieval of this data impossible. Option D would allow retrieval of student IDs given a subject, but not directly sorted by top score to find the top scorer for each subject efficiently. A GSI offers the flexibility to achieve the desired retrieval speeds without requiring multiple queries.
👍 2examuserss2024/12/26
シャッフルモード