0
0
DynamoDBquery~20 mins

Expression attribute names in DynamoDB - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Expression Attribute Names Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
Using Expression Attribute Names to Access Reserved Words

You have a DynamoDB table with an attribute named "Name", which is a reserved word. You want to update the attribute "Name" to "Alice" for the item with "ID" = 123.

Which update expression and expression attribute names will correctly update the item?

DynamoDB
UpdateExpression = "SET #N = :val"
ExpressionAttributeNames = {"#N": "Name"}
ExpressionAttributeValues = {":val": "Alice"}
AUpdateExpression = "SET Name = :val" without ExpressionAttributeNames
BUpdateExpression = "SET #N = :val" with ExpressionAttributeNames = {"#N": "Name"}
CUpdateExpression = "SET #Name = :val" with ExpressionAttributeNames = {"#Name": "Name"}
DUpdateExpression = "SET #N = :val" with ExpressionAttributeNames = {"#Name": "Name"}
Attempts:
2 left
💡 Hint

Reserved words require you to use expression attribute names with a placeholder starting with #.

📝 Syntax
intermediate
2:00remaining
Identify the Syntax Error in Expression Attribute Names Usage

Which option contains a syntax error in the use of expression attribute names in a DynamoDB update expression?

DynamoDB
UpdateExpression = "SET #A = :val"
ExpressionAttributeNames = {"#A": "Age"}
ExpressionAttributeValues = {":val": 30}
AExpressionAttributeNames = {"A": "Age"}
BExpressionAttributeNames = {"#A": "#Age"}
CExpressionAttributeNames = {"#A": "Age"}
DExpressionAttributeNames = {"#Age": "Age"}
Attempts:
2 left
💡 Hint

Expression attribute names must start with a # symbol in the key.

query_result
advanced
2:00remaining
Effect of Incorrect Expression Attribute Names Mapping

You run the following DynamoDB update command:

UpdateExpression = "SET #A = :val"
ExpressionAttributeNames = {"#B": "Age"}
ExpressionAttributeValues = {":val": 25}

What will happen when this command is executed?

AA runtime error occurs because #A is not defined in ExpressionAttributeNames
BThe attribute "Age" will be updated to 25
CThe attribute "#A" will be created and set to 25
DThe update will succeed but no attribute will be changed
Attempts:
2 left
💡 Hint

Check if all placeholders in UpdateExpression are defined in ExpressionAttributeNames.

optimization
advanced
2:00remaining
Optimizing Expression Attribute Names for Multiple Reserved Words

You want to update two reserved word attributes, "Status" and "Order", in a DynamoDB item. Which option uses expression attribute names most efficiently?

A
ExpressionAttributeNames = {"Status": "Status", "Order": "Order"}
UpdateExpression = "SET Status = :s, Order = :o"
B
ExpressionAttributeNames = {"#Status": "Status", "#Order": "Order"}
UpdateExpression = "SET #Status = :s, #Order = :o"
C
ExpressionAttributeNames = {"#S": "Status", "#S": "Order"}
UpdateExpression = "SET #S = :s, #S = :o"
D
ExpressionAttributeNames = {"#S": "Status", "#O": "Order"}
UpdateExpression = "SET #S = :s, #O = :o"
Attempts:
2 left
💡 Hint

Each placeholder must be unique and map to one attribute name.

🔧 Debug
expert
3:00remaining
Debugging a Complex UpdateExpression with Nested Attributes

You want to update a nested attribute "info.Name" in a DynamoDB item. The attribute "Name" is reserved. You write:

UpdateExpression = "SET #info.#N = :val"
ExpressionAttributeNames = {"#info": "info", "#N": "Name"}
ExpressionAttributeValues = {":val": "Bob"}

What will be the result of this update?

AThe attribute #info.#N will be created literally as a string key
BA syntax error occurs due to incorrect use of expression attribute names for nested attributes
CThe nested attribute info.Name will be updated to "Bob" successfully
DA runtime error occurs because nested attribute placeholders are not supported
Attempts:
2 left
💡 Hint

Expression attribute names can be used for nested attributes by prefixing each part.