0
0
DynamoDBquery~20 mins

Multiple actions in one update in DynamoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Master of Multiple Actions in One Update
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the result of this DynamoDB update expression?
Given a DynamoDB item with attributes {"count": 5, "tags": ["red", "blue"]}, what will be the value of the item after applying this update expression?

UpdateExpression: "SET count = count + :inc ADD tags :newTags"
ExpressionAttributeValues: {":inc": 3, ":newTags": {"SS": ["green"]}}
A{"count": 8, "tags": ["red", "blue", "green"]}
B{"count": 8, "tags": ["green"]}
C{"count": 3, "tags": ["red", "blue", "green"]}
D{"count": 5, "tags": ["red", "blue"]}
Attempts:
2 left
💡 Hint
Remember that ADD adds elements to a set attribute without removing existing ones.
📝 Syntax
intermediate
1:30remaining
Which update expression syntax is valid for multiple actions?
Which of the following DynamoDB update expressions correctly combines multiple actions in one statement?
ASET price = :p ADD tags :t REMOVE description
BSET price = :p, ADD tags :t REMOVE description
CSET price = :p; ADD tags :t; REMOVE description
DSET price = :p ADD tags :t, REMOVE description
Attempts:
2 left
💡 Hint
Multiple actions are separated by spaces, not commas or semicolons.
optimization
advanced
2:30remaining
Optimizing multiple attribute updates in one request
You want to update three attributes in a DynamoDB item: increment 'views' by 1, add 'new' to a set attribute 'labels', and remove the attribute 'temp'. Which approach is most efficient?
ASend three separate UpdateItem requests, one for each action.
BUse one UpdateItem request with UpdateExpression: 'SET views = views + :inc; ADD labels :newLabels; REMOVE temp'.
CUse one UpdateItem request with UpdateExpression: 'SET views = views + :inc, ADD labels :newLabels, REMOVE temp'.
DUse one UpdateItem request with UpdateExpression: 'SET views = views + :inc ADD labels :newLabels REMOVE temp'.
Attempts:
2 left
💡 Hint
Minimize network calls by combining actions in one request with correct syntax.
🔧 Debug
advanced
2:00remaining
Why does this multiple-action update fail?
You run this update expression:

UpdateExpression: "SET score = score + :val ADD tags :newTags REMOVE tags"
ExpressionAttributeValues: {":val": 10, ":newTags": {"SS": ["urgent"]}}


It returns a validation error. What is the cause?
AThe SET action cannot increment a numeric attribute.
BThe ADD action requires a numeric value, not a set.
CYou cannot ADD and REMOVE the same attribute in one update.
DExpressionAttributeValues is missing a value for :val.
Attempts:
2 left
💡 Hint
Think about conflicting actions on the same attribute in one update.
🧠 Conceptual
expert
3:00remaining
Understanding atomicity of multiple actions in one update
When you perform multiple actions (SET, ADD, REMOVE) in a single DynamoDB UpdateItem request, which statement is true about the operation?
AEach action is applied independently; some may succeed while others fail.
BAll actions are applied atomically; either all succeed or none are applied.
COnly the first action is guaranteed to succeed; others are best-effort.
DActions are queued and applied sequentially with possible partial updates.
Attempts:
2 left
💡 Hint
Think about DynamoDB's consistency and atomicity guarantees for UpdateItem.