Challenge - 5 Problems
DynamoDB ADD Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate1:30remaining
What is the result of this ADD expression?
Given a DynamoDB item with attribute
counter initially set to 5, what will be the value of counter after applying this update expression?UpdateExpression: "ADD counter :inc"ExpressionAttributeValues: {":inc": 3}Attempts:
2 left
💡 Hint
ADD increments the numeric attribute by the given value.
✗ Incorrect
The ADD expression increases the numeric attribute by the specified amount. Starting from 5, adding 3 results in 8.
📝 Syntax
intermediate1:30remaining
Which option is the correct syntax for incrementing a numeric attribute using ADD?
Choose the correct UpdateExpression and ExpressionAttributeValues to increment attribute
score by 10 in DynamoDB.Attempts:
2 left
💡 Hint
ADD requires a numeric value in ExpressionAttributeValues.
✗ Incorrect
Option A uses the correct syntax with ADD and a numeric value. Option A uses SET which is valid but not ADD. Option A is invalid syntax. Option A uses a string instead of a number.
❓ optimization
advanced2:00remaining
Why is using ADD better than SET for numeric increments in DynamoDB?
Consider two update expressions to increment attribute
1)
2)
Which statement about their behavior is correct?
visits by 1:1)
SET visits = visits + :inc2)
ADD visits :incWhich statement about their behavior is correct?
Attempts:
2 left
💡 Hint
Think about atomicity and performance of ADD vs SET.
✗ Incorrect
ADD is designed for atomic increments and does not require reading the current value, making it more efficient and safer for concurrent updates.
🔧 Debug
advanced1:30remaining
What error occurs with this ADD expression?
Given this update expression:
What error will DynamoDB raise?
UpdateExpression: "ADD total :val"ExpressionAttributeValues: {":val": "5"}What error will DynamoDB raise?
Attempts:
2 left
💡 Hint
Check the data type of the value used with ADD.
✗ Incorrect
ADD requires a numeric value. Providing a string causes a ValidationException from DynamoDB.
🧠 Conceptual
expert2:00remaining
What happens if the attribute does not exist when using ADD to increment?
If you use the update expression
ADD clicks :inc with :inc = 1 on an item that does not have the attribute clicks, what will be the result?Attempts:
2 left
💡 Hint
Think about how ADD behaves with missing numeric attributes.
✗ Incorrect
ADD creates the attribute with the increment value if it does not exist, initializing it to that number.