Recall & Review
beginner
What is a key condition expression in DynamoDB?
A key condition expression specifies the key values to search for in a DynamoDB table or index. It helps DynamoDB find items by matching the partition key and optionally the sort key.
Click to reveal answer
beginner
Which key(s) must be included in a key condition expression?
The partition key must always be included. The sort key can be included optionally with conditions like equals, less than, greater than, or between.
Click to reveal answer
intermediate
Example of a key condition expression to find items with partition key 'User123' and sort key greater than 100.
KeyConditionExpression: "UserId = :userId AND Score > :score"
ExpressionAttributeValues: {":userId": {"S": "User123"}, ":score": {"N": "100"}}
Click to reveal answer
intermediate
Can you use non-key attributes in a key condition expression?
No. Key condition expressions only work with the partition key and sort key attributes. Non-key attributes must be filtered using filter expressions after the query.
Click to reveal answer
intermediate
What operators can be used with the sort key in a key condition expression?
You can use =, <, <=, >, >=, BETWEEN, and BEGINS_WITH operators with the sort key in key condition expressions.
Click to reveal answer
Which key is mandatory in a DynamoDB key condition expression?
✗ Incorrect
The partition key must always be specified in a key condition expression to identify the partition to query.
Can you use a filter expression inside a key condition expression?
✗ Incorrect
Filter expressions are applied after the key condition expression to further filter results, but they are separate.
Which operator is NOT valid in a key condition expression for the sort key?
✗ Incorrect
The LIKE operator is not supported in key condition expressions; use BEGINS_WITH for prefix matching.
What happens if you omit the sort key in a key condition expression on a table with a composite key?
✗ Incorrect
If the sort key is omitted, the query returns all items with the specified partition key.
Which of these is a valid key condition expression?
✗ Incorrect
Only partition key and sort key attributes can be used in key condition expressions. Age and Status are non-key attributes.
Explain what a key condition expression is and why it is important in DynamoDB queries.
Think about how DynamoDB uses keys to find data quickly.
You got /4 concepts.
Describe the difference between key condition expressions and filter expressions in DynamoDB.
Consider when each expression is applied during a query.
You got /4 concepts.