Bird
0
0

Given a DynamoDB table with UserId as partition key and Timestamp as sort key, what will the following query return?

medium📝 service behavior Q4 of 15
AWS - DynamoDB

Given a DynamoDB table with UserId as partition key and Timestamp as sort key, what will the following query return?

Query: Get all items where UserId = '123' and Timestamp > '2023-01-01'
AAll items with UserId '123' regardless of Timestamp
BAll items with UserId '123' and Timestamp after '2023-01-01'
CAll items with Timestamp after '2023-01-01' regardless of UserId
DAn error because sort key cannot be used in queries
Step-by-Step Solution
Solution:
  1. Step 1: Understand query conditions

    Query filters items by partition key equality and sort key condition (greater than).
  2. Step 2: Apply conditions to result

    Only items with UserId '123' and Timestamp after '2023-01-01' are returned.
  3. Final Answer:

    All items with UserId '123' and Timestamp after '2023-01-01' -> Option B
  4. Quick Check:

    Query filters by partition and sort key conditions [OK]
Quick Trick: Query requires partition key equality and optional sort key condition [OK]
Common Mistakes:
  • Thinking sort key cannot be used in queries
  • Ignoring partition key condition
  • Assuming query returns all items with sort key condition only

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes