Complete the code to specify the partition key for a DynamoDB table storing hierarchical data.
KeySchema: [{ AttributeName: [1], KeyType: 'HASH' }]The partition key 'ParentId' groups all child items under the same parent for efficient hierarchical queries.
Complete the code to define the sort key for ordering child items under a parent in DynamoDB.
KeySchema: [{ AttributeName: 'ParentId', KeyType: 'HASH' }, { AttributeName: [1], KeyType: 'RANGE' }]The sort key 'ChildId' uniquely identifies and allows ordering of child items under the same parent.
Fix the error in the DynamoDB query to fetch all children of a parent item.
const params = { TableName: 'Items', KeyConditionExpression: '[1] = :parentId', ExpressionAttributeValues: { ':parentId': 'parent456' } };The KeyConditionExpression uses only the partition key 'ParentId = :parentId' to retrieve all children under the parent.
Fill both blanks to create a DynamoDB item representing a child with a reference to its parent.
Item: { 'ChildId': [1], 'ParentId': [2], 'Name': 'Child Item' }The 'ChildId' is the child's unique ID (sort key), and 'ParentId' references the parent's ID (partition key).
Fill all three blanks to write a DynamoDB query that retrieves all children of a parent sorted by child ID.
const params = { TableName: 'Items', KeyConditionExpression: '[1] = :parentId', ExpressionAttributeValues: { ':parentId': [2] }, ScanIndexForward: [3] };The query filters by 'ParentId' equal to the parent's ID and sorts results in ascending order by ChildId (ScanIndexForward: true).