0
0
DynamoDBquery~10 mins

Why Query is the primary read operation in DynamoDB - Test Your Understanding

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

Complete the code to query items from a DynamoDB table using the primary key.

DynamoDB
response = table.query(KeyConditionExpression=Key('[1]').eq('123'))
Drag options to blanks, or click blank then click option'
AFilterExpression
BScanIndexForward
CUserId
DProjectionExpression
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-key attribute in KeyConditionExpression causes errors.
Confusing FilterExpression with KeyConditionExpression.
2fill in blank
medium

Complete the code to sort query results in descending order.

DynamoDB
response = table.query(KeyConditionExpression=Key('UserId').eq('123'), [1]=False)
Drag options to blanks, or click blank then click option'
AFilterExpression
BScanIndexForward
CConsistentRead
DProjectionExpression
Attempts:
3 left
💡 Hint
Common Mistakes
Using FilterExpression to sort results.
Omitting ScanIndexForward and expecting descending order.
3fill in blank
hard

Fix the error in the query to use the correct key condition syntax.

DynamoDB
response = table.query(KeyConditionExpression=Key('UserId').[1]('123'))
Drag options to blanks, or click blank then click option'
Aeq
Bbegins_with
Ccontains
Dfilter
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'filter' which is not a valid method here.
Using 'contains' or 'begins_with' incorrectly for partition key.
4fill in blank
hard

Fill both blanks to query items with a partition key and sort key condition.

DynamoDB
response = table.query(KeyConditionExpression=Key('[1]').eq('123') & Key('[2]').[3]('2023-01-01'))
Drag options to blanks, or click blank then click option'
AUserId
BOrderDate
Cbegins_with
Deq
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'eq' for the sort key when a prefix match is needed.
Mixing up partition and sort key names.
5fill in blank
hard

Fill all three blanks to create a query that filters results and projects specific attributes.

DynamoDB
response = table.query(KeyConditionExpression=Key('[1]').eq('123'), FilterExpression=Attr('[2]').[3]('active'), ProjectionExpression='UserId, [2]')
Drag options to blanks, or click blank then click option'
AUserId
BStatus
Ceq
Dbegins_with
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'begins_with' instead of 'eq' in FilterExpression.
Not including the filtered attribute in ProjectionExpression.