0
0
DynamoDBquery~10 mins

Hierarchical data modeling 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 partition key for a DynamoDB table storing hierarchical data.

DynamoDB
KeySchema: [{ AttributeName: [1], KeyType: 'HASH' }]
Drag options to blanks, or click blank then click option'
AParentId
BItemId
CSortKey
DCategory
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ItemId' as partition key prevents efficient retrieval of all children under a parent.
2fill in blank
medium

Complete the code to define the sort key for ordering child items under a parent in DynamoDB.

DynamoDB
KeySchema: [{ AttributeName: 'ParentId', KeyType: 'HASH' }, { AttributeName: [1], KeyType: 'RANGE' }]
Drag options to blanks, or click blank then click option'
AParentId
BCategory
CTimestamp
DChildId
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ParentId' as sort key, which duplicates the partition key.
3fill in blank
hard

Fix the error in the DynamoDB query to fetch all children of a parent item.

DynamoDB
const params = { TableName: 'Items', KeyConditionExpression: '[1] = :parentId', ExpressionAttributeValues: { ':parentId': 'parent456' } };
Drag options to blanks, or click blank then click option'
AChildId
BCategory
CParentId
DSortKey
Attempts:
3 left
💡 Hint
Common Mistakes
Adding a sort key condition like 'ChildId = :id', which returns only one child.
4fill in blank
hard

Fill both blanks to create a DynamoDB item representing a child with a reference to its parent.

DynamoDB
Item: { 'ChildId': [1], 'ParentId': [2], 'Name': 'Child Item' }
Drag options to blanks, or click blank then click option'
A'child123'
B'parent456'
C'child456'
D'parent123'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping child and parent IDs.
5fill in blank
hard

Fill all three blanks to write a DynamoDB query that retrieves all children of a parent sorted by child ID.

DynamoDB
const params = { TableName: 'Items', KeyConditionExpression: '[1] = :parentId', ExpressionAttributeValues: { ':parentId': [2] }, ScanIndexForward: [3] };
Drag options to blanks, or click blank then click option'
AParentId
B'parent456'
Ctrue
DItemId
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'ItemId' instead of 'ParentId' in the condition.
Using false for ScanIndexForward when ascending order is needed.