Complete the code to create a DynamoDB table with a primary key.
aws dynamodb create-table --table-name Music --attribute-definitions AttributeName=Artist,AttributeType=S --key-schema AttributeName=[1],KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
The primary key must match the attribute defined. Here, 'Artist' is the primary key.
Complete the code to put an item into the DynamoDB table.
aws dynamodb put-item --table-name Music --item '{"Artist": {"S": "No One You Know"}, "SongTitle": {"S": [1]'
The SongTitle value must be a string in quotes. "Call Me Today" is the example song title.
Fix the error in the query to get an item by primary key.
aws dynamodb get-item --table-name Music --key '{"Artist": {"S": [1]'
The string value must be enclosed in double quotes inside the JSON string.
Fill both blanks to create a DynamoDB table with a composite primary key.
aws dynamodb create-table --table-name Music --attribute-definitions AttributeName=[1],AttributeType=S AttributeName=[2],AttributeType=S --key-schema AttributeName=Artist,KeyType=HASH AttributeName=SongTitle,KeyType=RANGE --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
The composite key uses 'Artist' as HASH and 'SongTitle' as RANGE key, so both must be defined as attributes.
Fill all three blanks to write a query that scans the table for items where Year is greater than 2010.
aws dynamodb scan --table-name Music --filter-expression "[1] [2] :yearVal" --expression-attribute-names '{"#yr": "[3]"}' --expression-attribute-values '{":yearVal": {"N": "2010"}}'
The filter expression uses the placeholder '#yr' for the attribute name 'Year' and the operator '>' to compare with 2010.