0
0
DynamoDBquery~10 mins

Why access patterns drive design 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 specify the primary key attribute name in a DynamoDB query.

DynamoDB
KeyConditionExpression = '#pk = :[1]'
Drag options to blanks, or click blank then click option'
Apartition_key
BuserId
Cpk_value
DpartitionKey
Attempts:
3 left
💡 Hint
Common Mistakes
Using an attribute name that does not exist in the table schema.
Confusing partition key with sort key names.
2fill in blank
medium

Complete the code to specify the index name for a DynamoDB query to support a specific access pattern.

DynamoDB
IndexName='[1]'
Drag options to blanks, or click blank then click option'
AGSI1
BPrimaryIndex
CLocalIndex
DSecondaryIndex
Attempts:
3 left
💡 Hint
Common Mistakes
Using the primary index name instead of the GSI name.
Using incorrect index names that do not exist.
3fill in blank
hard

Fix the error in the DynamoDB query expression to correctly filter items by sort key.

DynamoDB
KeyConditionExpression = '#pk = :userId AND [1] = :sortKeyVal'
Drag options to blanks, or click blank then click option'
Ask
Bsort_key
CsortKeyVal
DsortKey
Attempts:
3 left
💡 Hint
Common Mistakes
Using the full name 'sortKey' instead of the attribute name.
Using the value variable name instead of the attribute name.
4fill in blank
hard

Fill both blanks to create a DynamoDB query that uses a partition key and a begins_with condition on the sort key.

DynamoDB
KeyConditionExpression = '#pk = :userId AND begins_with(#[1], :[2])'
Drag options to blanks, or click blank then click option'
Ask
BsortKey
Cprefix
DskPrefix
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect attribute names for the sort key.
Confusing the prefix variable name with the attribute name.
5fill in blank
hard

Fill all three blanks to build a DynamoDB query that filters items by partition key, sort key greater than a value, and uses a specific index.

DynamoDB
response = table.query(IndexName='[1]', KeyConditionExpression='#pk = :userId AND #sk [2] :sortVal', ExpressionAttributeNames={'#pk': 'userId', '#sk': '[3]'}, ExpressionAttributeValues={':userId': '123', ':sortVal': '2023-01-01'})
Drag options to blanks, or click blank then click option'
AGSI2
B>
CcreatedAt
DPrimaryIndex
Attempts:
3 left
💡 Hint
Common Mistakes
Using the primary index name instead of the GSI.
Using '=' instead of '>' for the sort key condition.
Mismatching attribute names in ExpressionAttributeNames.