0
0
DynamoDBquery~20 mins

Expression attribute values in DynamoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Expression Attribute Values Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the output of this DynamoDB update expression?
Given a DynamoDB table with an item having id = 101 and attribute score = 50, what will be the new value of score after running this update?

UpdateExpression: "SET score = score + :inc"
ExpressionAttributeValues: {":inc": {"N": "20"}}
AThe score will be updated to 70
BThe score will be updated to 20
CThe update will fail due to missing attribute
DThe score will remain 50
Attempts:
2 left
💡 Hint
Remember that :inc is a placeholder for the value 20 used in the update expression.
📝 Syntax
intermediate
1:30remaining
Which ExpressionAttributeValues syntax is correct for a string value?
You want to update an attribute status to the string value active. Which of the following ExpressionAttributeValues is valid?
A{ ":val": { "BOOL": "active" } }
B{ ":val": "active" }
C{ ":val": { "N": "active" } }
D{ ":val": { "S": "active" } }
Attempts:
2 left
💡 Hint
DynamoDB expects data types like S for string, N for number, BOOL for boolean.
optimization
advanced
2:30remaining
How to efficiently update multiple attributes using ExpressionAttributeValues?
You want to update attributes age to 30 and city to "Seattle" in one update call. Which ExpressionAttributeValues and UpdateExpression combination is correct and efficient?
AUpdateExpression: "SET age = :a, city = :c"<br>ExpressionAttributeValues: {":a": {"N": "30"}, ":c": {"S": "Seattle"}}
BUpdateExpression: "SET age = 30, city = 'Seattle'"<br>ExpressionAttributeValues: {}
CUpdateExpression: "SET age = :age, city = :city"<br>ExpressionAttributeValues: {":age": 30, ":city": "Seattle"}
DUpdateExpression: "SET age = :a, city = :c"<br>ExpressionAttributeValues: {":a": 30, ":c": "Seattle"}
Attempts:
2 left
💡 Hint
ExpressionAttributeValues must specify data types for values.
🔧 Debug
advanced
2:00remaining
Why does this update fail with a ValidationException?
Given this update:

UpdateExpression: "SET name = :n"
ExpressionAttributeValues: {":n": {"N": "John"}}


Why does DynamoDB return a ValidationException error?
ABecause the placeholder ":n" is missing in the UpdateExpression
BBecause the data type "N" is used for a string value instead of "S"
CBecause the attribute name "name" is a reserved word and needs aliasing
DBecause ExpressionAttributeValues cannot contain nested objects
Attempts:
2 left
💡 Hint
Check the data type used for the value "John".
🧠 Conceptual
expert
3:00remaining
What is the purpose of ExpressionAttributeValues in DynamoDB operations?
Choose the best explanation for why ExpressionAttributeValues are used in DynamoDB queries and updates.
AThey store the results returned by DynamoDB after a query or scan operation
BThey define the schema of the table and enforce data types on attributes
CThey act as placeholders to safely substitute values in expressions, preventing injection and syntax errors
DThey are used to create indexes on attributes for faster querying
Attempts:
2 left
💡 Hint
Think about how placeholders help in writing safe and reusable expressions.