Complete the code to create a DynamoDB table with a primary key.
aws dynamodb create-table --table-name Users --attribute-definitions AttributeName=UserId,AttributeType=S --key-schema AttributeName=[1],KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
The primary key attribute name must match the attribute defined in the attribute definitions. Here, 'UserId' is the correct primary key.
Complete the code to add an item with a string attribute 'Name' to the DynamoDB table.
aws dynamodb put-item --table-name Users --item '{"UserId": {"S": "123"}, "Name": [1]'
String attributes in DynamoDB are represented with the 'S' type.
Fix the error in the code to query items by 'UserId' equals '123'.
aws dynamodb query --table-name Users --key-condition-expression "UserId = [1]" --expression-attribute-values '{":v1": {"S": "123"}}'
The key condition expression must use the placeholder ':v1' with a colon and quotes.
Fill both blanks to update the 'Email' attribute of an item with 'UserId' 123.
aws dynamodb update-item --table-name Users --key '{"UserId": {"S": "123"}}' --update-expression "SET [1] = :email" --expression-attribute-values '{":email": {"S": [2]'
The update expression must set the 'Email' attribute, and the new email value must be a string in quotes.
Fill all three blanks to create a table with a composite primary key: partition key 'UserId' and sort key 'Timestamp'.
aws dynamodb create-table --table-name UserActivity --attribute-definitions AttributeName=[1],AttributeType=S AttributeName=[2],AttributeType=N --key-schema AttributeName=[3],KeyType=HASH AttributeName=Timestamp,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
The attribute definitions must include both 'UserId' (string) and 'Timestamp' (number). The key schema uses 'UserId' as HASH (partition key) and 'Timestamp' as RANGE (sort key).