0
0
DynamoDBquery~10 mins

Adjacency list 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 specify the parent ID attribute in the DynamoDB item.

DynamoDB
item = {"id": "123", "[1]": "456"}
Drag options to blanks, or click blank then click option'
AparentId
BchildId
CnodeId
DrootId
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'childId' instead of 'parentId' confuses the direction of the relationship.
Using generic names like 'nodeId' does not clarify the parent-child link.
2fill in blank
medium

Complete the code to query all items with a specific parent ID using DynamoDB's Query operation.

DynamoDB
response = table.query(KeyConditionExpression=Key('parentId').[1]('456'))
Drag options to blanks, or click blank then click option'
Abegins_with
Bcontains
Ceq
Dbetween
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'begins_with' when you want an exact match.
Using 'contains' which is for non-key attributes.
3fill in blank
hard

Fix the error in the code to correctly insert a child node with a parent reference.

DynamoDB
table.put_item(Item={"id": "789", "[1]": "123"})
Drag options to blanks, or click blank then click option'
AchildId
BparentId
Cparent_key
DrootId
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'childId' which is not the standard attribute for parent reference.
Using 'parent_key' which is not recognized by the schema.
4fill in blank
hard

Fill both blanks to create a DynamoDB query that retrieves all children of a given parent ID.

DynamoDB
response = table.query(KeyConditionExpression=Key('[1]').[2]('001'))
Drag options to blanks, or click blank then click option'
AparentId
Beq
Cbegins_with
DchildId
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'childId' instead of 'parentId' in the query.
Using 'begins_with' when an exact match is needed.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that maps child IDs to their parent IDs from a list of items.

DynamoDB
child_to_parent = {item['[1]']: item['[2]'] for item in items if item['[3]'] is not None}
Drag options to blanks, or click blank then click option'
Aid
BparentId
DchildId
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'childId' as the key which is not the standard attribute for the child's ID.
Not filtering out items where parentId is None.