0
0
DynamoDBquery~30 mins

Why CRUD operations are foundational in DynamoDB - See It in Action

Choose your learning style9 modes available
Why CRUD Operations Are Foundational in DynamoDB
📖 Scenario: You are building a simple contact list app that stores people's names and phone numbers using DynamoDB. You want to learn how to add, read, update, and delete contacts in your database.
🎯 Goal: Build a basic DynamoDB table and practice the four main CRUD operations: Create, Read, Update, and Delete contacts.
📋 What You'll Learn
Create a DynamoDB table named Contacts with ContactID as the primary key.
Add a new contact with a specific ContactID, Name, and PhoneNumber.
Read a contact's details by ContactID.
Update the PhoneNumber of an existing contact.
Delete a contact by ContactID.
💡 Why This Matters
🌍 Real World
Managing contacts, products, or any data records in apps requires CRUD operations to keep data accurate and up to date.
💼 Career
Understanding CRUD in DynamoDB is essential for backend developers, database administrators, and cloud engineers working with AWS services.
Progress0 / 4 steps
1
Create the DynamoDB table and add a contact
Create a DynamoDB table named Contacts with ContactID as the primary key. Then add a contact with ContactID set to "1", Name set to "Alice", and PhoneNumber set to "123-456-7890".
DynamoDB
Need a hint?

Use boto3.resource('dynamodb') to connect. Create the table with ContactID as the HASH key. Use put_item to add the contact.

2
Set up a variable to hold the contact ID to read
Create a variable called contact_id and set it to the string "1". This will be used to read the contact details.
DynamoDB
Need a hint?

Just create a variable named contact_id and assign it the string '1'.

3
Read the contact details using the contact ID
Use the get_item method on contacts_table to get the contact with ContactID equal to the variable contact_id. Store the result in a variable called response.
DynamoDB
Need a hint?

Use contacts_table.get_item(Key={'ContactID': contact_id}) and assign it to response.

4
Update the contact's phone number and then delete the contact
Use the update_item method on contacts_table to change the PhoneNumber of the contact with ContactID equal to contact_id to "987-654-3210". Then use the delete_item method to remove the contact with ContactID equal to contact_id.
DynamoDB
Need a hint?

Use update_item with UpdateExpression to change the phone number. Then use delete_item with the key to remove the contact.