Courseiva
Workload-Specific Database DesignmediumMultiple ChoiceObjective-mapped

DBS-C01 Workload-Specific Database Design Practice Question

A social media application stores user posts in a DynamoDB table with a partition key of user_id and a sort key of timestamp. The most frequent query is to retrieve the 10 most recent posts for a given user. Which secondary index design would optimize this query?

⚠ Common exam trap

Watch out — candidates often choose Option A (GSI) because they think a GSI is always the answer for query optimization, but they overlook that an LSI is more appropriate when the partition key is the same as the base table and the query pattern is a simple range query on an existing attribute, avoiding unnecessary cost and complexity.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

Create an LSI with user_id as the partition key and timestamp as the sort key.

A Local Secondary Index (LSI) on the base table with the same partition key (user_id) and a sort key of timestamp allows efficient retrieval of the 10 most recent posts for a given user. An LSI shares the same partition key as the base table, so querying by user_id with ScanIndexForward=false and Limit=10 returns the most recent items without needing to replicate data or incur additional write costs.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • Create a GSI with user_id as the partition key and timestamp as the sort key.

    Why it's wrong here

    A GSI would work but is overkill and adds cost compared to an LSI.

  • Use DynamoDB Streams to populate an Amazon Elasticsearch cluster for search queries.

    Why it's wrong here

    DynamoDB Streams feeding Elasticsearch addresses full-text search and complex analytics, but the query requires retrieving the 10 most recent posts per user_id—a simple sorted range query on timestamp. Elasticsearch introduces latency from stream processing and eventual consistency, whereas a local secondary index on user_id with timestamp as sort key would serve the read directly from DynamoDB with strong consistency. This option is tempting because Elasticsearch excels at fuzzy text search across all users’ posts, which would be correct for a keyword-search feature, not for fetching a fixed number of recent items per partition.

  • Create an LSI with user_id as the partition key and timestamp as the sort key.

    Why this is correct

    An LSI uses the same partition key and a different sort key, enabling efficient range queries.

  • Query the base table using the sort key timestamp with a limit of 10.

    Why it's wrong here

    Without an LSI, the query would require a full scan of all items for the user.

About these practice questions

This DBS-C01 question is part of Courseiva's 1,663-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This DBS-C01 practice question is part of Courseiva's free Amazon Web Services certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the DBS-C01 exam.