0
0
DynamoDBquery~30 mins

SET expression for adding/changing in DynamoDB - Mini Project: Build & Apply

Choose your learning style9 modes available
Using SET Expression to Add or Change Attributes in DynamoDB
📖 Scenario: You are managing a DynamoDB table that stores information about books in a library. You want to update the details of a book by adding new attributes or changing existing ones.
🎯 Goal: Build a DynamoDB update expression using the SET keyword to add or change attributes of a book item.
📋 What You'll Learn
Create a dictionary called book_item with keys 'BookID', 'Title', and 'Author' with exact values.
Create a variable called update_expression that uses the SET keyword to add or change attributes.
Create a dictionary called expression_attribute_values with the exact keys and values used in the update expression.
Create a dictionary called update_params that includes the table name, key, update expression, and expression attribute values.
💡 Why This Matters
🌍 Real World
Updating items in DynamoDB tables is common when managing data for applications like libraries, inventories, or user profiles.
💼 Career
Knowing how to write update expressions with SET is essential for backend developers and database administrators working with AWS DynamoDB.
Progress0 / 4 steps
1
Create the initial book item dictionary
Create a dictionary called book_item with these exact entries: 'BookID': 'B1001', 'Title': 'Learn DynamoDB', and 'Author': 'Jane Doe'.
DynamoDB
Need a hint?

Use curly braces {} to create a dictionary with the exact keys and values.

2
Create the update expression string
Create a variable called update_expression and set it to the string "SET Title = :new_title, Publisher = :publisher" to update the title and add a new attribute Publisher.
DynamoDB
Need a hint?

The SET expression updates existing attributes or adds new ones. Use placeholders like :new_title.

3
Create the expression attribute values dictionary
Create a dictionary called expression_attribute_values with keys :new_title set to 'Mastering DynamoDB' and :publisher set to 'Tech Books Publishing'.
DynamoDB
Need a hint?

Use a dictionary with keys matching the placeholders in the update expression and values as the new data.

4
Create the update parameters dictionary
Create a dictionary called update_params with keys: TableName set to 'Library', Key set to {'BookID': 'B1001'}, UpdateExpression set to update_expression, and ExpressionAttributeValues set to expression_attribute_values.
DynamoDB
Need a hint?

Combine all parts into one dictionary to use in the DynamoDB update call.