Complete the code to define a composite primary key with partition key 'UserId'.
KeySchema: [{ AttributeName: 'UserId', KeyType: '[1]' }]The partition key in DynamoDB is defined with KeyType 'HASH'.
Complete the code to add a sort key named 'OrderId' in the composite primary key.
KeySchema: [
{ AttributeName: 'UserId', KeyType: 'HASH' },
{ AttributeName: 'OrderId', KeyType: '[1]' }
]The sort key in DynamoDB is defined with KeyType 'RANGE'.
Fix the error in the attribute definitions for the composite primary key.
AttributeDefinitions: [
{ AttributeName: 'UserId', AttributeType: '[1]' },
{ AttributeName: 'OrderId', AttributeType: 'S' }
]Both partition and sort keys must have a valid attribute type. 'S' means string type.
Fill both blanks to complete the table creation with composite primary key.
CreateTable({
TableName: 'Orders',
KeySchema: [
{ AttributeName: '[1]', KeyType: 'HASH' },
{ AttributeName: '[2]', KeyType: 'RANGE' }
],
AttributeDefinitions: [
{ AttributeName: 'UserId', AttributeType: 'S' },
{ AttributeName: 'OrderId', AttributeType: 'S' }
]
})The composite primary key uses 'UserId' as partition key and 'OrderId' as sort key.
Fill all three blanks to define a composite primary key and attribute types correctly.
CreateTable({
TableName: 'Purchases',
KeySchema: [
{ AttributeName: '[1]', KeyType: 'HASH' },
{ AttributeName: '[2]', KeyType: 'RANGE' }
],
AttributeDefinitions: [
{ AttributeName: '[1]', AttributeType: 'S' },
{ AttributeName: '[2]', AttributeType: 'N' }
]
})The partition key is 'CustomerId' with type 'S' (string), and the sort key is 'PurchaseDate' with type 'N' (number).