0
0
DynamoDBquery~10 mins

Identifying access patterns first 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 specify the primary key attribute name in a DynamoDB table creation.

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
Choosing a non-unique attribute like 'Status' as primary key.
2fill in blank
medium

Complete the code to define a Global Secondary Index (GSI) partition key.

DynamoDB
GlobalSecondaryIndexes: [{ IndexName: 'StatusIndex', KeySchema: [{ AttributeName: [1], KeyType: 'HASH' }] }]
Drag options to blanks, or click blank then click option'
AUserId
BEmail
CTimestamp
DStatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using the primary key attribute 'UserId' as GSI key.
3fill in blank
hard

Fix the error in the query to get an item by primary key.

DynamoDB
const params = { TableName: 'Users', Key: { [1]: '12345' } };
Drag options to blanks, or click blank then click option'
AStatus
BEmail
CUserId
DTimestamp
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-primary key attribute in the Key object.
4fill in blank
hard

Fill both blanks to create a query using a GSI to find items by status and sort by timestamp.

DynamoDB
const params = { TableName: 'Orders', IndexName: 'StatusIndex', KeyConditionExpression: '[1] = :statusVal AND [2] > :timeVal', ExpressionAttributeValues: { ':statusVal': 'shipped', ':timeVal': 1609459200 } };
Drag options to blanks, or click blank then click option'
AStatus
BUserId
CTimestamp
DOrderId
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping partition and sort key names.
5fill in blank
hard

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

DynamoDB
const params = { TableName: 'Tasks', Key: { TaskId: 'task123' }, UpdateExpression: 'SET [1] = :newStatus, [2] = [3] + :inc', ExpressionAttributeValues: { ':newStatus': 'completed', ':inc': 1 } };
Drag options to blanks, or click blank then click option'
AStatus
BCounter
CCount
DProgress
Attempts:
3 left
💡 Hint
Common Mistakes
Using different attribute names for increment operation.