nerdexam
Amazon

DVA-C02 · Question #377

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

The correct answer is C. Create a global secondary index (GSI) with subject_name as the partition key and top_score as. A Global Secondary Index (GSI) with subject_name as the partition key and top_score as the sort key enables efficient queries that retrieve items for a given subject sorted by score descending, yielding the top scorer.

Submitted by haru.x· Mar 5, 2026Development with AWS Services

Question

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?

Options

  • ACreate a local secondary index (LSI) with subject_name as the partition key and top_score as the
  • BCreate a local secondary index (LSI) with top_score as the partition key and student_id as the
  • CCreate a global secondary index (GSI) with subject_name as the partition key and top_score as
  • DCreate a global secondary index (GSI) with subject_name as the partition key and student_id as

How the community answered

(31 responses)
  • A
    16% (5)
  • B
    3% (1)
  • C
    74% (23)
  • D
    6% (2)

Why each option

A Global Secondary Index (GSI) with subject_name as the partition key and top_score as the sort key enables efficient queries that retrieve items for a given subject sorted by score descending, yielding the top scorer.

ACreate a local secondary index (LSI) with subject_name as the partition key and top_score as the

An LSI cannot change the partition key away from student_id; it must share the base table partition key, so a query on subject_name as the partition key is not possible with an LSI.

BCreate a local secondary index (LSI) with top_score as the partition key and student_id as the

An LSI with top_score as the partition key is invalid because an LSI must use the same partition key as the base table (student_id), and using top_score as a partition key distributes data poorly.

CCreate a global secondary index (GSI) with subject_name as the partition key and top_score asCorrect

With subject_name as the GSI partition key, all exam scores for a given subject are grouped together in the index. Using top_score as the sort key means DynamoDB stores them in score order, allowing the application to query the GSI for a subject and retrieve items sorted by top_score efficiently. The student_id attribute is projected into the index and returned in the query results.

DCreate a global secondary index (GSI) with subject_name as the partition key and student_id as

A GSI with subject_name as partition key and student_id as sort key groups items by subject but sorts by student_id, not score, making it impossible to efficiently identify the top scorer without reading and sorting all items in application code.

Concept tested: DynamoDB GSI design for top-N queries by sort key

Source: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/GSI.html

Community Discussion

No community discussion yet for this question.

Full DVA-C02 Practice