0
0
DynamoDBquery~5 mins

PutItem (creating items) in DynamoDB - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the PutItem operation do in DynamoDB?
PutItem adds a new item or replaces an old item with a new one in a DynamoDB table.
Click to reveal answer
beginner
Which key attribute must you always include when using PutItem?
You must include the primary key attribute(s) defined for the table, such as the partition key and optionally the sort key.
Click to reveal answer
intermediate
What happens if you use PutItem with an item that has the same primary key as an existing item?
The existing item is completely replaced by the new item you provide.
Click to reveal answer
intermediate
How can you prevent overwriting an existing item when using PutItem?
Use a condition expression to check that the item does not already exist before inserting.
Click to reveal answer
beginner
Give an example of a simple PutItem request in DynamoDB.
Example: {"TableName": "Users", "Item": {"UserId": {"S": "123"}, "Name": {"S": "Alice"}}}
Click to reveal answer
What does PutItem do if the item key already exists in the table?
AIt replaces the entire existing item with the new item.
BIt deletes the old item and inserts the new one.
CIt updates only the specified attributes.
DIt returns an error and does nothing.
Which attribute is mandatory in the Item you provide to PutItem?
AThe primary key attribute(s) of the table.
BAny attribute you want to add.
CA timestamp attribute.
DA condition expression.
How can you avoid overwriting an existing item when using PutItem?
ADelete the item first.
BUse UpdateItem instead.
CUse a condition expression to check item existence.
DPutItem always overwrites; you cannot avoid it.
What is the minimum required parameter for a PutItem request?
ATableName only.
BTableName and Item.
CItem only.
DConditionExpression.
If you want to add a new user with ID '101' and name 'Bob', which is a valid PutItem Item format?
A{"UserId": {"N": "101"}, "Name": {"S": "Bob"}}
B{"UserId": "101", "Name": "Bob"}
C{"UserId": 101, "Name": "Bob"}
D{"UserId": {"S": "101"}, "Name": {"S": "Bob"}}
Explain how PutItem works in DynamoDB and what happens if the item key already exists.
Think about inserting and overwriting items.
You got /3 concepts.
    Describe how to prevent overwriting an existing item when using PutItem.
    Conditions can control when PutItem succeeds.
    You got /3 concepts.