0
0
DynamoDBquery~10 mins

One-to-many relationship patterns 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 attribute name for the main table.

DynamoDB
TableName: 'Orders', KeySchema: [{ AttributeName: '[1]', KeyType: 'HASH' }]
Drag options to blanks, or click blank then click option'
AOrderId
BCustomerId
CProductId
DDate
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'CustomerId' as partition key causes multiple orders to share the same key.
Choosing 'ProductId' or 'Date' does not uniquely identify orders.
2fill in blank
medium

Complete the code to add a sort key attribute for storing multiple items per order.

DynamoDB
KeySchema: [{ AttributeName: 'OrderId', KeyType: 'HASH' }, { AttributeName: '[1]', KeyType: 'RANGE' }]
Drag options to blanks, or click blank then click option'
AOrderDate
BCustomerId
CItemId
DStatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'CustomerId' as sort key does not separate items within an order.
Choosing 'OrderDate' or 'Status' does not uniquely identify items.
3fill in blank
hard

Fix the error in the query to fetch all items for a specific order using the partition key.

DynamoDB
const params = { TableName: 'Orders', KeyConditionExpression: 'OrderId = [1]', ExpressionAttributeValues: { ':orderId': '12345' } };
Drag options to blanks, or click blank then click option'
AorderId
BOrderId
C#OrderId
D:orderId
Attempts:
3 left
💡 Hint
Common Mistakes
Using attribute names directly instead of placeholders causes errors.
Missing the colon ':' before the placeholder.
4fill in blank
hard

Fill both blanks to create a query that fetches items for an order with a specific item ID.

DynamoDB
KeyConditionExpression: 'OrderId = [1] AND ItemId = [2]', ExpressionAttributeValues: { ':orderId': '12345', ':itemId': 'A1' }
Drag options to blanks, or click blank then click option'
A:orderId
B:itemId
COrderId
DItemId
Attempts:
3 left
💡 Hint
Common Mistakes
Using attribute names instead of placeholders in the expression.
Mixing placeholders and attribute names incorrectly.
5fill in blank
hard

Fill all three blanks to define a DynamoDB item with a partition key, sort key, and an attribute for quantity.

DynamoDB
Item: { 'OrderId': [1], 'ItemId': [2], 'Quantity': [3] }
Drag options to blanks, or click blank then click option'
A'12345'
B'A1'
C10
D'Customer1'
Attempts:
3 left
💡 Hint
Common Mistakes
Using numbers for keys instead of strings.
Putting quotes around numbers like quantity.