0
0
DynamoDBquery~10 mins

Sparse index pattern 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 create a sparse index by specifying the attribute to index.

DynamoDB
KeySchema: [{ AttributeName: [1], KeyType: 'HASH' }]
Drag options to blanks, or click blank then click option'
ACategory
BPrice
CDescription
DStock
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing an attribute that exists on all items, which makes the index not sparse.
Using an attribute that is not defined in the table's attribute definitions.
2fill in blank
medium

Complete the code to define the projection type for the sparse index.

DynamoDB
Projection: { ProjectionType: [1] }
Drag options to blanks, or click blank then click option'
AKEYS_ONLY
BALL
CINCLUDE
DNONE
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ALL' projection which copies all attributes and increases index size.
Using 'NONE' which is not a valid projection type.
3fill in blank
hard

Fix the error in the attribute definition for the sparse index.

DynamoDB
AttributeDefinitions: [{ AttributeName: 'Category', AttributeType: [1] }]
Drag options to blanks, or click blank then click option'
AB
BN
CBOOL
DS
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'N' for a string attribute causes type mismatch errors.
Using 'BOOL' which is not a valid AttributeType.
4fill in blank
hard

Fill both blanks to complete the sparse index creation with correct key schema and projection.

DynamoDB
GlobalSecondaryIndexes: [{ IndexName: 'CategoryIndex', KeySchema: [{ AttributeName: [1], KeyType: 'HASH' }], Projection: { ProjectionType: [2] } }]
Drag options to blanks, or click blank then click option'
ACategory
BALL
CKEYS_ONLY
DPrice
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Price' as partition key which is not the sparse attribute.
Using 'ALL' projection which increases index size unnecessarily.
5fill in blank
hard

Fill all three blanks to define a sparse index with attribute definitions, key schema, and projection type.

DynamoDB
AttributeDefinitions: [{ AttributeName: [1], AttributeType: [2] }], GlobalSecondaryIndexes: [{ IndexName: 'CategoryIndex', KeySchema: [{ AttributeName: [3], KeyType: 'HASH' }], Projection: { ProjectionType: 'KEYS_ONLY' } }]
Drag options to blanks, or click blank then click option'
ACategory
BS
CPrice
DN
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatch between attribute names in definitions and key schema.
Using 'Price' or 'N' when the sparse attribute is a string.