Bird
0
0

You want to retrieve all items with a partition key 'Category' equal to 'Books' and a sort key 'Price' less than 20. Which DynamoDB operation and parameters should you use?

hard📝 Application Q9 of 15
AWS - DynamoDB
You want to retrieve all items with a partition key 'Category' equal to 'Books' and a sort key 'Price' less than 20. Which DynamoDB operation and parameters should you use?
AScan with FilterExpression 'Category = :c and Price < :p'
BQuery with KeyConditionExpression 'Category = :c and Price < :p'
CGetItem with Key containing Category and Price conditions
DPutItem with ConditionExpression 'Category = :c and Price < :p'
Step-by-Step Solution
Solution:
  1. Step 1: Identify operation for partition and sort key conditions

    Query supports filtering by partition key and sort key using KeyConditionExpression.
  2. Step 2: Eliminate other options

    Scan can filter but is less efficient; GetItem retrieves one item by key; PutItem is for writing.
  3. Final Answer:

    Query with KeyConditionExpression 'Category = :c and Price < :p' -> Option B
  4. Quick Check:

    Query filters by partition and sort key conditions [OK]
Quick Trick: Use Query with KeyConditionExpression for partition and sort key filters [OK]
Common Mistakes:
MISTAKES
  • Using Scan instead of Query
  • Trying GetItem for multiple items
  • Using PutItem for retrieval

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes