0
0
AWScloud~30 mins

Partition key and sort key in AWS - Mini Project: Build & Apply

Choose your learning style9 modes available
Partition key and sort key
📖 Scenario: You are building a simple database table in AWS DynamoDB to store information about books in a library. Each book has a unique ISBN number and a title. You want to organize the table so that you can quickly find books by their ISBN and also sort them by their title within the same ISBN.
🎯 Goal: Create a DynamoDB table with a partition key and a sort key. The partition key should be ISBN to uniquely identify each book. The sort key should be Title to allow sorting books by their title within the same ISBN.
📋 What You'll Learn
Create a DynamoDB table named LibraryBooks.
Use ISBN as the partition key of type string.
Use Title as the sort key of type string.
Set the billing mode to PAY_PER_REQUEST for simplicity.
💡 Why This Matters
🌍 Real World
DynamoDB tables with partition and sort keys are used in many applications to store and query data efficiently, such as user profiles, product catalogs, and event logs.
💼 Career
Understanding partition and sort keys is essential for cloud architects and developers working with AWS DynamoDB to design scalable and performant NoSQL databases.
Progress0 / 4 steps
1
Create the basic table structure
Create a DynamoDB table resource named LibraryBooks with an empty AttributeDefinitions and KeySchema arrays.
AWS
Need a hint?

Start by defining the DynamoDB table resource with empty attribute and key schema lists.

2
Define the partition key attribute
Add an attribute definition for the partition key named ISBN of type S (string) inside AttributeDefinitions. Also add a key schema entry for the partition key with AttributeName as ISBN and KeyType as HASH.
AWS
Need a hint?

The partition key is the main key to find items. Use HASH for partition key.

3
Add the sort key attribute
Add an attribute definition for the sort key named Title of type S inside AttributeDefinitions. Also add a key schema entry for the sort key with AttributeName as Title and KeyType as RANGE.
AWS
Need a hint?

The sort key helps sort items with the same partition key. Use RANGE for sort key.

4
Complete the table configuration
Ensure the table name is set to LibraryBooks in the Properties section.
AWS
Need a hint?

Set the TableName property to the exact table name.