Bird
0
0

Consider a DynamoDB table with OrderId as the partition key and OrderDate as the sort key. What is the issue with this query?

medium📝 Debug Q7 of 15
AWS - DynamoDB

Consider a DynamoDB table with OrderId as the partition key and OrderDate as the sort key. What is the issue with this query?

KeyConditionExpression = "OrderDate = :date"
AThe query syntax is correct and will return all matching items.
BThe sort key cannot be used in KeyConditionExpression.
CThe attribute name <code>OrderDate</code> is invalid for queries.
DThe query must include the partition key in the KeyConditionExpression.
Step-by-Step Solution
Solution:
  1. Step 1: Understand KeyConditionExpression requirements

    Queries require the partition key to be specified in the KeyConditionExpression.
  2. Step 2: Analyze given expression

    The expression only filters on the sort key OrderDate, missing the partition key OrderId.
  3. Step 3: Conclusion

    Without the partition key, the query is invalid and will fail.
  4. Final Answer:

    The query must include the partition key in the KeyConditionExpression. -> Option D
  5. Quick Check:

    Partition key mandatory in query condition [OK]
Quick Trick: Queries require partition key condition [OK]
Common Mistakes:
MISTAKES
  • Using only sort key in KeyConditionExpression
  • Assuming sort key alone can filter items
  • Ignoring partition key requirement in queries

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More AWS Quizzes