0
0
DynamoDBquery~10 mins

Why table design determines performance 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 for a DynamoDB table.

DynamoDB
KeySchema: [{ AttributeName: 'UserId', KeyType: '[1]' }]
Drag options to blanks, or click blank then click option'
APRIMARY
BRANGE
CHASH
DINDEX
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'RANGE' instead of 'HASH' for the partition key.
Confusing 'PRIMARY' or 'INDEX' as KeyType values.
2fill in blank
medium

Complete the code to add a sort key to the DynamoDB table design.

DynamoDB
KeySchema: [ { AttributeName: 'UserId', KeyType: 'HASH' }, { AttributeName: 'Timestamp', KeyType: '[1]' } ]
Drag options to blanks, or click blank then click option'
APRIMARY
BRANGE
CSORT
DINDEX
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'HASH' instead of 'RANGE' for the sort key.
Using 'SORT' or 'PRIMARY' which are not valid KeyType values.
3fill in blank
hard

Fix the error in the attribute definition for the partition key.

DynamoDB
AttributeDefinitions: [ { AttributeName: 'UserId', AttributeType: '[1]' } ]
Drag options to blanks, or click blank then click option'
AS
BN
CB
DBOOL
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'N' (number) when the key is a string.
Using 'B' (binary) or 'BOOL' which are not typical for keys.
4fill in blank
hard

Fill both blanks to create a Global Secondary Index (GSI) with a partition and sort key.

DynamoDB
GlobalSecondaryIndexes: [{ IndexName: 'StatusIndex', KeySchema: [ { AttributeName: '[1]', KeyType: 'HASH' }, { AttributeName: '[2]', KeyType: 'RANGE' } ], Projection: { ProjectionType: 'ALL' } }]
Drag options to blanks, or click blank then click option'
AStatus
BCreatedAt
CUserId
DTimestamp
Attempts:
3 left
💡 Hint
Common Mistakes
Using the main table keys instead of GSI keys.
Mixing up partition and sort keys.
5fill in blank
hard

Fill all three blanks to create a DynamoDB query filtering items by partition key and a condition on the sort key.

DynamoDB
const params = { TableName: 'Orders', KeyConditionExpression: '#pk = :pkVal AND [1] [2] :sortVal', ExpressionAttributeNames: { '#pk': '[3]' }, ExpressionAttributeValues: { ':pkVal': '123', ':sortVal': 20230101 } };
Drag options to blanks, or click blank then click option'
ATimestamp
B>
COrderId
D=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '=' instead of '>' for the sort key condition.
Mixing up attribute names in ExpressionAttributeNames.