0
0
DynamoDBquery~10 mins

GSI key selection strategy 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 partition key for a GSI in DynamoDB.

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 a sort key attribute as the partition key.
Choosing an attribute with low cardinality.
2fill in blank
medium

Complete the code to define the sort key for a GSI in DynamoDB.

DynamoDB
KeySchema: [ { AttributeName: 'UserId', KeyType: 'HASH' }, { AttributeName: '[1]', KeyType: 'RANGE' } ]
Drag options to blanks, or click blank then click option'
AOrderId
BUserId
CStatus
DEmail
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same attribute for partition and sort key.
Choosing an attribute that does not help with sorting.
3fill in blank
hard

Fix the error in the GSI attribute definitions by selecting the correct attribute type.

DynamoDB
AttributeDefinitions: [ { AttributeName: 'UserId', AttributeType: '[1]' }, { AttributeName: 'OrderDate', AttributeType: 'S' } ]
Drag options to blanks, or click blank then click option'
ABOOL
BS
CB
DN
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'N' (number) for string attributes.
Using 'BOOL' for non-boolean attributes.
4fill in blank
hard

Fill both blanks to create a GSI that uses 'Status' as partition key and 'CreatedAt' as 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
DOrderId
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping partition and sort keys.
Using attributes not defined in AttributeDefinitions.
5fill in blank
hard

Fill all three blanks to define a GSI with keys and projection type.

DynamoDB
GlobalSecondaryIndexes: [{ IndexName: 'EmailIndex', KeySchema: [ { AttributeName: '[1]', KeyType: 'HASH' }, { AttributeName: '[2]', KeyType: 'RANGE' } ], Projection: { ProjectionType: '[3]' } }]
Drag options to blanks, or click blank then click option'
AEmail
BSignupDate
CALL
DKEYS_ONLY
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong projection types like 'INCLUDE' without specifying attributes.
Mixing up HASH and RANGE keys.