Data Modeling in AWS DynamoDB

How to model your data to work with Amazon Web Services’ NoSQL based DynamoDB.

Jake Richards
May 31, 2019 · 5 min read
Image for post
Image for post

Why NoSQL?

Why DynamoDB?

Understanding the Basics

Partition Key

Hot Partitions

Sort Key

An Example of Data Modeling

Image for post
Image for post
Image for post
Image for post
{
"TableName": "tournaments",
"KeyConditionExpression": "partitionKey = :tournamentId",
"ExpressionAttributeValues": {
":tournamentId": "983d39a3-bdd6-4b61-88d5-58595d555b81"
}
}

What if you only want the teams for a given tournament id?

{
"TableName": "tournaments",
"KeyConditionExpression": "partitionKey = :tournamentId and begins_with(sortKey, :teamPrefix)",
"ExpressionAttributeValues": {
":teamPrefix": "team-",
":tournamentId": "983d39a3-bdd6-4b61-88d5-58595d555b81"
}
}

What if you only want the basic details?

{
"TableName": "tournaments",
"Key": {
"partitionKey": "983d39a3-bdd6-4b61-88d5-58595d555b81",
"sortKey": "tournament-details"
}
}

Wrapping Up

The Startup

Medium's largest active publication, followed by +721K people. Follow to join our community.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store