Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What does 'Multiple actions in one update' mean in DynamoDB?
It means you can change several attributes of an item in a single update request, like adding, removing, or modifying multiple fields at once.
Click to reveal answer
beginner
Which DynamoDB operation allows multiple attribute changes in one call?
The UpdateItem operation lets you perform multiple actions like SET, REMOVE, ADD, and DELETE on different attributes in one request.
Click to reveal answer
intermediate
How do you add a new attribute and remove an old one in a single DynamoDB update?
Use the UpdateExpression with SET to add or change an attribute and REMOVE to delete another attribute in the same UpdateItem call.
Click to reveal answer
intermediate
What is the role of ExpressionAttributeNames and ExpressionAttributeValues in multiple updates?
They help safely reference attribute names and values in the update expression, especially if names are reserved words or contain special characters.
Click to reveal answer
intermediate
Can you perform arithmetic operations on attributes during a multiple action update?
Yes, you can use the ADD action in UpdateExpression to increment or decrement numeric attributes in the same update request.
Click to reveal answer
Which DynamoDB update action is used to remove an attribute?
AREMOVE
BDELETE
CSET
DADD
✗ Incorrect
REMOVE is the correct action to delete an attribute from an item in DynamoDB.
How do you update multiple attributes in one DynamoDB UpdateItem call?
AUse a single UpdateExpression with multiple actions
BUse multiple UpdateItem calls
CUse Scan operation
DUse Query operation
✗ Incorrect
A single UpdateExpression can include multiple actions like SET, REMOVE, ADD to update several attributes at once.
What does the ADD action do in a DynamoDB update?
ARemoves an attribute
BAdds a new attribute only
CIncrements or decrements numeric attributes or adds elements to sets
DReplaces the entire item
✗ Incorrect
ADD can increment/decrement numbers or add elements to set attributes in DynamoDB.
Why use ExpressionAttributeNames in an update?
ATo rename the table
BTo avoid conflicts with reserved words or special characters in attribute names
CTo encrypt attribute values
DTo specify the primary key
✗ Incorrect
ExpressionAttributeNames let you safely reference attribute names that might be reserved words or have special characters.
Can you remove and add attributes in the same UpdateItem request?
ANo, you must do separate requests
BOnly if attributes are strings
COnly if attributes are numeric
DYes, by combining REMOVE and SET actions in UpdateExpression
✗ Incorrect
You can combine REMOVE and SET actions in one UpdateExpression to remove and add attributes together.
Explain how to perform multiple attribute updates in a single DynamoDB UpdateItem call.
Think about how you can combine different actions in one expression.
You got /4 concepts.
Describe the purpose of the ADD action in DynamoDB updates and give an example.
Consider how you might increase a number without replacing it.
You got /3 concepts.
Practice
(1/5)
1. In DynamoDB, which update action allows you to change or add new attributes to an item in a single update request?
easy
A. REMOVE
B. SET
C. ADD
D. DELETE
Solution
Step 1: Understand update actions in DynamoDB
DynamoDB update expressions use SET to add or modify attributes in an item.
Step 2: Identify the correct action for adding or changing attributes
SET is used to add new attributes or change existing ones in a single update request.
Final Answer:
SET -> Option B
Quick Check:
SET updates attributes [OK]
Hint: Use SET to add or change attributes in one update [OK]
Common Mistakes:
Confusing REMOVE with adding attributes
Using ADD to change non-numeric attributes
Thinking DELETE removes attributes instead of set elements
2. Which of the following is the correct syntax to update an attribute score by adding 10 in a DynamoDB update expression?
easy
A. DELETE score 10
B. SET score = score + 10
C. REMOVE score + 10
D. ADD score 10
Solution
Step 1: Recall syntax for numeric increments in DynamoDB
To increase a numeric attribute, DynamoDB uses ADD followed by the attribute and the value.
Step 2: Match the correct syntax
ADD score 10 correctly adds 10 to the existing score attribute.
Final Answer:
ADD score 10 -> Option D
Quick Check:
ADD increments numbers [OK]
Hint: Use ADD to increase numeric attributes in update [OK]
Common Mistakes:
Using SET with arithmetic expressions (not supported)
Using REMOVE or DELETE for numeric increments
Incorrect syntax like missing commas or keywords
3. Given the following update expression: SET age = age + :inc REMOVE nickname ADD points :pts DELETE tags :oldTags What will happen if the item initially has age = 30, nickname = 'Sam', points = 5, and tags = {'red', 'blue'} with :inc = 2, :pts = 3, and :oldTags = {'blue'}?
medium
A. age becomes 2, nickname removed, points become 8, tags become {'red', 'blue'}
B. age becomes 32, nickname removed, points become 3, tags become {'red', 'blue'}
C. age becomes 32, nickname removed, points become 8, tags become {'red'}
D. age becomes 32, nickname unchanged, points become 8, tags become {'red'}
Solution
Step 1: Apply each update action to the initial item
SET age = age + :inc adds 2 to 30 -> 32; REMOVE nickname deletes 'Sam'; ADD points :pts adds 3 to 5 -> 8; DELETE tags :oldTags removes 'blue' from {'red', 'blue'} -> {'red'}.
Step 2: Confirm final attribute values
age=32, nickname removed, points=8, tags={'red'} matches age becomes 32, nickname removed, points become 8, tags become {'red'}.
Final Answer:
age becomes 32, nickname removed, points become 8, tags become {'red'} -> Option C
Quick Check:
Multiple actions update all attributes correctly [OK]
Hint: Apply each action step-by-step to see final values [OK]
Common Mistakes:
Forgetting REMOVE deletes attribute
Confusing DELETE with REMOVE for sets
Misapplying ADD to sets instead of numbers
4. Identify the error in this DynamoDB update expression: SET name = :n ADD age :a REMOVE points, DELETE tags :t
medium
A. Comma after REMOVE points is invalid syntax
B. ADD cannot be used with a non-numeric attribute like age
C. SET cannot assign a value using a placeholder like :n
D. REMOVE and DELETE cannot be used together in one update
Solution
Step 1: Check syntax for multiple update actions
REMOVE action lists attributes separated by spaces, not commas. The comma after points is invalid.
Step 2: Validate other parts
ADD can be used with numeric attributes; SET can use placeholders; REMOVE and DELETE can coexist.
Final Answer:
Comma after REMOVE points is invalid syntax -> Option A
Quick Check:
REMOVE uses spaces, not commas [OK]
Hint: Use spaces, not commas, to separate REMOVE attributes [OK]
Common Mistakes:
Using commas in REMOVE or DELETE lists
Assuming ADD works on non-numeric attributes
Thinking placeholders are not allowed in SET
5. You want to update a DynamoDB item to do all these in one update: - Increase stock by 5 - Remove attribute discontinued - Add newTag to a set attribute tags Which update expression correctly performs all these actions?
hard
A. ADD stock :inc REMOVE discontinued ADD tags :newTag
B. SET stock = stock + :inc REMOVE discontinued ADD tags :newTag
C. ADD stock :inc REMOVE discontinued SET tags = tags + :newTag
D. SET stock = stock + :inc DELETE discontinued ADD tags :newTag
Solution
Step 1: Choose correct action for increasing numeric attribute
ADD stock :inc correctly increases numeric stock by :inc.
Step 2: Remove attribute and add to set correctly
REMOVE discontinued deletes the attribute; ADD tags :newTag adds elements to the set.
Step 3: Verify syntax correctness
ADD stock :inc REMOVE discontinued ADD tags :newTag uses ADD for numeric and set additions, REMOVE for attribute removal, all valid.