0
0
AWScloud~10 mins

Tables, items, and attributes in AWS - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a DynamoDB table with a primary key.

AWS
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
Drag options to blanks, or click blank then click option'
AUserId
BUsername
CEmail
DId
Attempts:
3 left
💡 Hint
Common Mistakes
Using an attribute name not defined in attribute-definitions.
2fill in blank
medium

Complete the code to add an item with a string attribute 'Name' to the DynamoDB table.

AWS
aws dynamodb put-item --table-name Users --item '{"UserId": {"S": "123"}, "Name": [1]'
Drag options to blanks, or click blank then click option'
A{"B": "John"}
B{"BOOL": "John"}
C{"S": "John"}
D{"N": "John"}
Attempts:
3 left
💡 Hint
Common Mistakes
Using number or boolean type for string attributes.
3fill in blank
hard

Fix the error in the code to query items by 'UserId' equals '123'.

AWS
aws dynamodb query --table-name Users --key-condition-expression "UserId = [1]" --expression-attribute-values '{":v1": {"S": "123"}}'
Drag options to blanks, or click blank then click option'
A":v1"
B"123"
C:v1
DUserId
Attempts:
3 left
💡 Hint
Common Mistakes
Using the raw value instead of the placeholder in the expression.
4fill in blank
hard

Fill both blanks to update the 'Email' attribute of an item with 'UserId' 123.

AWS
aws dynamodb update-item --table-name Users --key '{"UserId": {"S": "123"}}' --update-expression "SET [1] = :email" --expression-attribute-values '{":email": {"S": [2]'
Drag options to blanks, or click blank then click option'
AEmail
B"new.email@example.com"
C"old.email@example.com"
DName
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong attribute name or missing quotes around the new email.
5fill in blank
hard

Fill all three blanks to create a table with a composite primary key: partition key 'UserId' and sort key 'Timestamp'.

AWS
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
Drag options to blanks, or click blank then click option'
AUserId
BActivity
DTimestamp
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing attribute names or types, or incorrect key schema roles.