Comparing Local Secondary Index (LSI) and Global Secondary Index (GSI) in DynamoDB
📖 Scenario: You are building a simple DynamoDB table to store information about books in a library. You want to learn how to use Local Secondary Indexes (LSI) and Global Secondary Indexes (GSI) to query the data in different ways.
🎯 Goal: Create a DynamoDB table with a primary key and add one Local Secondary Index (LSI) and one Global Secondary Index (GSI). Understand how to define them and see the difference in their setup.
📋 What You'll Learn
Create a DynamoDB table named
Books with Author as the partition key and Title as the sort key.Add a Local Secondary Index (LSI) named
GenreIndex with Author as the partition key and Genre as the sort key.Add a Global Secondary Index (GSI) named
PublisherIndex with Publisher as the partition key and Year as the sort key.Use the AWS CLI JSON format for the table creation and index definitions.
💡 Why This Matters
🌍 Real World
In real-world applications, DynamoDB indexes help you query data efficiently in different ways without scanning the entire table.
💼 Career
Understanding LSIs and GSIs is important for database developers and cloud engineers working with AWS DynamoDB to optimize data access patterns.
Progress0 / 4 steps