Recall & Review
beginner
What is a conditional expression in DynamoDB?
A conditional expression is a way to specify a condition that must be true for a write operation (like PutItem, UpdateItem, or DeleteItem) to succeed. It helps prevent overwriting or deleting data unintentionally.
Click to reveal answer
beginner
How do you use a conditional expression to check if an attribute exists before updating it?
You use the function
attribute_exists(attributeName) in the condition expression. For example, ConditionExpression: "attribute_exists(#pid)" with ExpressionAttributeNames: {"#pid": "ProductID"} ensures the item exists before updating.Click to reveal answer
beginner
What happens if a conditional expression evaluates to false during a write operation?
The write operation fails and DynamoDB returns a
ConditionalCheckFailedException. This means the data is not changed because the condition was not met.Click to reveal answer
beginner
Name two logical operators you can use in DynamoDB conditional expressions.
You can use
AND and OR to combine multiple conditions in a conditional expression.Click to reveal answer
beginner
How can you check if an attribute does NOT exist in a DynamoDB item using a conditional expression?
Use the function
attribute_not_exists(attributeName). For example, ConditionExpression: "attribute_not_exists(#oid)" with ExpressionAttributeNames: {"#oid": "OrderID"} ensures the attribute is missing before proceeding.Click to reveal answer
What does a conditional expression do in DynamoDB?
✗ Incorrect
Conditional expressions ensure that a write operation only happens if the specified condition is true.
Which function checks if an attribute exists in a DynamoDB item?
✗ Incorrect
The function attribute_exists() returns true if the attribute is present in the item.
What error does DynamoDB return if a conditional expression fails?
✗ Incorrect
When a conditional expression evaluates to false, DynamoDB returns ConditionalCheckFailedException.
Which logical operator can you use to combine conditions in DynamoDB conditional expressions?
✗ Incorrect
AND is a logical operator used to combine multiple conditions in DynamoDB conditional expressions.
How do you check that an attribute does NOT exist before inserting a new item?
✗ Incorrect
attribute_not_exists(attributeName) returns true if the attribute is missing, useful to avoid overwriting existing items.
Explain what a conditional expression is in DynamoDB and why it is useful.
Think about how you can protect your data from accidental changes.
You got /3 concepts.
Describe how to use attribute_exists and attribute_not_exists functions in conditional expressions.
These functions help control when updates or inserts happen.
You got /3 concepts.