0
0
DynamoDBquery~30 mins

NoSQL vs relational database comparison in DynamoDB - Hands-On Comparison

Choose your learning style9 modes available
NoSQL vs Relational Database Comparison with DynamoDB
📖 Scenario: You are working for a small online bookstore. You want to store information about books and their authors. You will use DynamoDB, a NoSQL database, to create and query this data.This project will help you understand how to set up data in a NoSQL database and compare it with relational database concepts.
🎯 Goal: Create a DynamoDB table to store books with their authors, add a configuration for a query, write a query to find books by a specific author, and complete the setup with a final attribute.
📋 What You'll Learn
Create a DynamoDB table called Books with BookID as the primary key and attributes Title and Author.
Add a variable called author_name to specify the author to query.
Write a query to find all books by the author stored in author_name.
Add a final attribute Genre to the table items.
💡 Why This Matters
🌍 Real World
Online stores and apps often use NoSQL databases like DynamoDB to store flexible data about products and users. This project shows how to organize and query such data.
💼 Career
Understanding how to create tables, add data, and query in DynamoDB is essential for roles like cloud developer, database administrator, and backend engineer working with AWS.
Progress0 / 4 steps
1
Create DynamoDB table with books data
Create a DynamoDB table called Books with BookID as the primary key. Add three items with these exact values: {'BookID': '1', 'Title': 'The Great Gatsby', 'Author': 'F. Scott Fitzgerald'}, {'BookID': '2', 'Title': '1984', 'Author': 'George Orwell'}, and {'BookID': '3', 'Title': 'To Kill a Mockingbird', 'Author': 'Harper Lee'}.
DynamoDB
Need a hint?

Use boto3.resource('dynamodb') to get the DynamoDB resource. Then create a table object with dynamodb.Table('Books'). Use put_item to add each book.

2
Add author_name variable for query
Create a variable called author_name and set it to the string 'George Orwell' to specify the author you want to find books for.
DynamoDB
Need a hint?

Just create a variable named author_name and assign the string 'George Orwell' to it.

3
Query books by author_name
Write a query using Books.scan() with a filter expression to find all books where the Author attribute equals the value in author_name. Use boto3.dynamodb.conditions.Attr for the filter expression and store the result in a variable called response.
DynamoDB
Need a hint?

Use Books.scan() with FilterExpression=Attr('Author').eq(author_name) to find matching books.

4
Add Genre attribute to books
Add the Genre attribute to each book item in the Books table with these exact values: 'Classic' for BookID '1', 'Dystopian' for BookID '2', and 'Historical Fiction' for BookID '3'. Use put_item to update the items.
DynamoDB
Need a hint?

Update each put_item call to include the Genre attribute with the correct value.