0
0
DynamoDBquery~30 mins

Key-value and document store model in DynamoDB - Mini Project: Build & Apply

Choose your learning style9 modes available
Create a Simple Product Catalog in DynamoDB
📖 Scenario: You are building a simple product catalog for an online store. Each product has a unique ID, a name, and a price. You will use DynamoDB, a key-value and document store database, to store and manage this data.
🎯 Goal: Create a DynamoDB table and add product items using the key-value and document store model. You will set up the table, configure a price threshold, query products above that price, and finally add a tag to the table for identification.
📋 What You'll Learn
Create a DynamoDB table named Products with ProductID as the primary key.
Add three products with exact details: ProductID, Name, and Price.
Create a variable price_threshold set to 100.
Query the table to find products with Price greater than price_threshold.
Add a tag Environment with value Test to the Products table.
💡 Why This Matters
🌍 Real World
Online stores and applications use DynamoDB to store product catalogs because it handles key-value and document data efficiently and scales well.
💼 Career
Knowing how to create tables, add items, query with filters, and tag resources is essential for cloud database management roles and backend development.
Progress0 / 4 steps
1
Create the DynamoDB table and add products
Create a DynamoDB table named Products with ProductID as the primary key. Add these exact product items: {'ProductID': 'P001', 'Name': 'Laptop', 'Price': 1200}, {'ProductID': 'P002', 'Name': 'Mouse', 'Price': 25}, and {'ProductID': 'P003', 'Name': 'Keyboard', 'Price': 75}.
DynamoDB
Need a hint?

Use boto3.resource('dynamodb') to get the DynamoDB resource. Use Table('Products') to reference the table. Use put_item to add each product with the exact keys and values.

2
Set the price threshold
Create a variable called price_threshold and set it to 100.
DynamoDB
Need a hint?

Just create a variable named price_threshold and assign it the value 100.

3
Query products with price above threshold
Use the scan method on the Products table with a filter expression to get items where Price is greater than price_threshold. Store the result in a variable called expensive_products.
DynamoDB
Need a hint?

Use from boto3.dynamodb.conditions import Attr and then use FilterExpression=Attr('Price').gt(price_threshold) inside scan().

4
Add a tag to the DynamoDB table
Add a tag to the Products table with key Environment and value Test using the DynamoDB client.
DynamoDB
Need a hint?

Create a DynamoDB client with boto3.client('dynamodb'). Use tag_resource with ResourceArn=Products.table_arn and the tag list.