0
0
DynamoDBquery~10 mins

Key condition expressions in DynamoDB - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to query items with a specific partition key.

DynamoDB
response = table.query(KeyConditionExpression=Key('UserId').[1](':user_id'))
Drag options to blanks, or click blank then click option'
A==
Bequals
C=
Deq
Attempts:
3 left
💡 Hint
Common Mistakes
Using Python equality operators like '==' or '=' instead of the DynamoDB method 'eq'.
Using 'equals' which is not a valid method in DynamoDB expressions.
2fill in blank
medium

Complete the code to query items with a partition key and sort key greater than a value.

DynamoDB
response = table.query(KeyConditionExpression=Key('UserId').eq(':user_id') & Key('Timestamp').[1](':time_val'))
Drag options to blanks, or click blank then click option'
Agt
Blt
Ceq
Dlte
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'lt' which means less than, the opposite of what is needed.
Using 'eq' which checks for equality, not greater than.
3fill in blank
hard

Fix the error in the key condition expression to query items with a partition key and sort key less than or equal to a value.

DynamoDB
response = table.query(KeyConditionExpression=Key('UserId').eq(':user_id') & Key('Timestamp').[1](':time_val'))
Drag options to blanks, or click blank then click option'
Agt
Bgte
Clte
Dlt
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'lt' which means strictly less than, not including equal.
Using 'gte' or 'gt' which filter for greater values.
4fill in blank
hard

Fill both blanks to query items with a partition key equal to a value and a sort key between two values.

DynamoDB
response = table.query(KeyConditionExpression=Key('UserId').[1](':user_id') & Key('Timestamp').[2](':start_time', ':end_time'))
Drag options to blanks, or click blank then click option'
Aeq
Bgt
Cbetween
Dlt
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'gt' or 'lt' for the partition key which requires equality.
Using 'eq' for the sort key when a range is needed.
5fill in blank
hard

Fill all three blanks to query items with a partition key equal to a value, a sort key greater than a value, and less than or equal to another value.

DynamoDB
response = table.query(KeyConditionExpression=Key('UserId').[1](':user_id') & Key('Timestamp').[2](':start_time') & Key('Timestamp').[3](':end_time'))
Drag options to blanks, or click blank then click option'
Aeq
Bgt
Clte
Dlt
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'lt' instead of 'lte' for the upper bound.
Using 'eq' for sort key conditions instead of range comparisons.