Given a DynamoDB table Orders with CustomerID as the partition key and OrderDate as the sort key (stored as ISO date strings), which query will return all orders for CustomerID = 'C123' placed between 2023-01-01 and 2023-01-31 inclusive?
Use the BETWEEN operator to include both start and end dates.
Option C uses BETWEEN which includes both boundary values. Option C is invalid because it uses two conditions on the sort key, which is not allowed in KeyConditionExpression. Option C excludes boundary dates. Option C only queries one date.
In a DynamoDB table Messages with UserID as partition key and MessageID as sort key, which query will return all messages for UserID = 'U456' where MessageID starts with '2023-06-'?
Use the begins_with function to filter sort keys starting with a prefix.
Option A correctly uses begins_with on the sort key. Option A checks for exact match, which is too strict. Option A tries BETWEEN but the end value is invalid and may miss some keys. Option A uses contains which is not allowed in KeyConditionExpression.
Which of the following KeyConditionExpression strings will cause a syntax error when querying a DynamoDB table with partition key PK and sort key SK?
Check which operators are allowed in KeyConditionExpression.
The IN operator is not supported in KeyConditionExpression. Options A, C, and D use valid operators: >, BETWEEN, and begins_with.
You want to query a DynamoDB table Events with partition key EventType and sort key EventTimestamp. You want to get all events of type 'click' after 2024-01-01T00:00:00Z. Which query condition is most efficient to minimize read capacity units consumed?
Use key conditions to reduce data scanned, not filters.
Option A uses both partition key and sort key conditions in KeyConditionExpression, which efficiently narrows data. Option A and D use FilterExpression which filters after reading data, consuming more read capacity. Option A does not filter by timestamp, returning more data.
Which statement about DynamoDB KeyConditionExpression for sort keys is FALSE?
Consider how many conditions on sort key are allowed in KeyConditionExpression.
Option B is false because you cannot combine multiple sort key conditions with AND; only one condition on the sort key is allowed in KeyConditionExpression. Options A, B, and D are true statements.