Create a DynamoDB Table with Secondary Indexes
📖 Scenario: You are building a simple inventory system using AWS DynamoDB. You want to create a table that stores product information. To efficiently query products by category and by supplier, you will add secondary indexes.
🎯 Goal: Create a DynamoDB table named Products with a primary key and add a Global Secondary Index (GSI) and a Local Secondary Index (LSI) to support queries by Category and Supplier.
📋 What You'll Learn
Create a DynamoDB table named
Products with ProductID as the partition key (string).Add a Local Secondary Index (LSI) named
CategoryIndex with ProductID as partition key and Category as sort key.Add a Global Secondary Index (GSI) named
SupplierIndex with Supplier as partition key and Price as sort key.Set the billing mode to
PAY_PER_REQUEST.💡 Why This Matters
🌍 Real World
Secondary indexes in DynamoDB help you query your data efficiently without scanning the entire table, which is important for performance and cost.
💼 Career
Understanding how to configure GSIs and LSIs is essential for AWS cloud architects and developers working with NoSQL databases to optimize data access patterns.
Progress0 / 4 steps