Bird
0
0

You have a DynamoDB table with a GSI on 'Category' (partition key) and 'Price' (sort key). You want to find all items in 'Electronics' category priced below 100. Which query approach is correct?

hard📝 Application Q8 of 15
AWS - DynamoDB
You have a DynamoDB table with a GSI on 'Category' (partition key) and 'Price' (sort key). You want to find all items in 'Electronics' category priced below 100. Which query approach is correct?
AQuery the GSI with Category='Electronics' and use a sort key condition Price < 100.
BScan the base table filtering Category='Electronics' and Price < 100.
CQuery the base table with Category='Electronics' and Price < 100.
DQuery the GSI with Price < 100 only.
Step-by-Step Solution
Solution:
  1. Step 1: Use GSI keys for efficient query

    GSI partition key is 'Category', so query must specify Category='Electronics'.
  2. Step 2: Apply sort key condition

    Sort key 'Price' can be filtered with Price < 100 in the query condition.
  3. Final Answer:

    Query the GSI with Category='Electronics' and use a sort key condition Price < 100. -> Option A
  4. Quick Check:

    GSI query = Partition key + sort key filter [OK]
Quick Trick: GSI queries require partition key; sort key filters narrow results [OK]
Common Mistakes:
  • Querying GSI without partition key
  • Using base table query instead of GSI
  • Scanning instead of querying for efficiency

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes