Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a DynamoDB table named 'Users'.
DynamoDB
aws dynamodb create-table --table-name [1] --attribute-definitions AttributeName=UserId,AttributeType=S --key-schema AttributeName=UserId,KeyType=HASH --provisioned-throughput ReadCapacityUnits=5,WriteCapacityUnits=5
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong table name like 'Customers' or 'Orders'.
Leaving the table name blank.
✗ Incorrect
The table name must be 'Users' as specified in the instruction.
2fill in blank
mediumComplete the code to add an item with UserId '123' to the 'Users' table.
DynamoDB
aws dynamodb put-item --table-name Users --item '{"UserId": {"S": "[1]"}}'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a different UserId value.
Forgetting to put quotes around the UserId.
✗ Incorrect
The UserId must be '123' as specified to add the correct item.
3fill in blank
hardFix the error in the code to get an item with UserId '123' from the 'Users' table.
DynamoDB
aws dynamodb get-item --table-name Users --key '{"UserId": {"[1]": "123"}}'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'N' which is for numbers.
Using 'B' which is for binary data.
✗ Incorrect
The key type for UserId is string, so it must be 'S'.
4fill in blank
hardFill both blanks to update the 'Email' attribute of user '123' in the 'Users' table.
DynamoDB
aws dynamodb update-item --table-name Users --key '{"UserId": {"S": "123"}}' --update-expression "set [1] = :e" --expression-attribute-values '{":e": {"[2]": "user@example.com"}}'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong attribute names like 'UserEmail'.
Using wrong data types like 'N' for string values.
✗ Incorrect
The attribute to update is 'Email' and its type is string 'S'.
5fill in blank
hardFill all three blanks to delete the item with UserId '123' from the 'Users' table.
DynamoDB
aws dynamodb delete-item --table-name [1] --key '{"UserId": {"[2]": "[3]"}}'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong table names like 'Orders'.
Using wrong key types or values.
✗ Incorrect
The table is 'Users', the key type is string 'S', and the UserId is '123'.