0
0
DynamoDBquery~10 mins

Single-table design methodology 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 define the primary key attribute name for a DynamoDB table.

DynamoDB
KeySchema: [{ AttributeName: '[1]', KeyType: 'HASH' }]
Drag options to blanks, or click blank then click option'
AUserId
BTimestamp
CEmail
DStatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using an attribute that is not unique as the primary key.
Confusing sort key with partition key.
2fill in blank
medium

Complete the code to add a sort key attribute name in the table schema.

DynamoDB
KeySchema: [ { AttributeName: 'UserId', KeyType: 'HASH' }, { AttributeName: '[1]', KeyType: 'RANGE' } ]
Drag options to blanks, or click blank then click option'
ACategory
BEmail
CStatus
DTimestamp
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-sortable attribute as the sort key.
Omitting the sort key when multiple items share the partition key.
3fill in blank
hard

Fix the error in the DynamoDB query to fetch items by partition key.

DynamoDB
Table.query({ KeyConditionExpression: 'UserId = :userId', ExpressionAttributeValues: { ':userId': [1] } })
Drag options to blanks, or click blank then click option'
AuserId
B'12345'
C12345
D:userId
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the variable name instead of its value.
Omitting quotes around string values.
4fill in blank
hard

Fill both blanks to create a DynamoDB item with partition key and sort key attributes.

DynamoDB
Item: { 'UserId': [1], 'Timestamp': [2], 'Data': 'Sample' }
Drag options to blanks, or click blank then click option'
A'user123'
B'2024-06-01T12:00:00Z'
C123456
D'dataValue'
Attempts:
3 left
💡 Hint
Common Mistakes
Using numbers instead of strings for keys.
Mixing up partition key and sort key values.
5fill in blank
hard

Fill all three blanks to write a DynamoDB update expression that sets a new attribute and increments a counter.

DynamoDB
UpdateExpression: 'SET [1] = :val, [2] = [3] + :inc', ExpressionAttributeValues: { ':val': 'active', ':inc': 1 }
Drag options to blanks, or click blank then click option'
AStatus
BCounter
CCount
DState
Attempts:
3 left
💡 Hint
Common Mistakes
Using different attribute names for increment operation.
Forgetting to repeat the attribute name in the increment expression.