Bird
0
0

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

medium📝 Predict Output Q13 of 15
AWS - DynamoDB

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

Query: KeyConditionExpression = "CustomerId = :cid AND InvoiceDate > :date"

Assuming :cid is '123' and :date is '2023-01-01'.

AAll invoices for customer '123' regardless of date.
BAll invoices for customer '123' with dates after January 1, 2023.
CAll invoices for all customers with dates after January 1, 2023.
DAll invoices with dates before January 1, 2023.
Step-by-Step Solution
Solution:
  1. Step 1: Understand KeyConditionExpression

    The query filters items where partition key CustomerId equals '123' and sort key InvoiceDate is greater than '2023-01-01'.
  2. Step 2: Interpret the filter effect

    This returns all invoices for customer '123' with InvoiceDate after January 1, 2023.
  3. Final Answer:

    All invoices for customer '123' with dates after January 1, 2023. -> Option B
  4. Quick Check:

    Partition key = '123' AND sort key > '2023-01-01' [OK]
Quick Trick: Partition key filters customer, sort key filters date range [OK]
Common Mistakes:
MISTAKES
  • Ignoring partition key filter
  • Assuming query returns all customers
  • Confusing greater than with less than

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes