Create and Query a Global Secondary Index (GSI) in DynamoDB
📖 Scenario: You are building a simple product catalog database using DynamoDB. You want to store products with their ProductID as the main key. Later, you want to quickly find products by their Category using a Global Secondary Index (GSI).
🎯 Goal: Create a DynamoDB table with a primary key ProductID, add a Global Secondary Index (GSI) on Category, and write a query to find all products in a specific category.
📋 What You'll Learn
Create a DynamoDB table named
Products with ProductID as the partition key.Add a Global Secondary Index named
CategoryIndex with Category as the partition key.Insert sample product items with
ProductID, Name, and Category attributes.Write a query using the GSI
CategoryIndex to find all products in the category Electronics.💡 Why This Matters
🌍 Real World
Global Secondary Indexes let you query DynamoDB tables efficiently by attributes other than the primary key, which is common in real-world applications like product catalogs, user profiles, and event logs.
💼 Career
Understanding GSIs is essential for database engineers and backend developers working with DynamoDB to design scalable and performant NoSQL databases.
Progress0 / 4 steps