AWS Builder Center

What My First DynamoDB Data Modeling Exercise Taught Me

My first hands-on experience with DynamoDB taught me to think about data modeling differently. Here are the key concepts I learned around access patterns, partition keys, sort keys, and data distribution.

Technical Product Consultant
While working through an AWS DynamoDB football data-modeling challenge, I had my first hands-on experience with DynamoDB and NoSQL Workbench.
The exercise introduced me to concepts such as access patterns, partition keys, sort keys, and partition distribution. These terms are easy to define, but understanding how they influence a data model became much clearer when I applied them to an actual data-modeling problem.
Here are the key lessons I took away.

Start with access patterns

One of the most important concepts I learned was access patterns.
An access pattern describes how an application needs to retrieve or work with data.
For example, with football data, we may need to answer questions such as:
  • Which matches are associated with a team?
  • How do I find a particular match?
  • How should related match information be retrieved?
This changes where we start when designing the data model.
Instead of beginning with:
What should my table look like?
start with:
What questions does the application need the database to answer?
The answers help determine how the data should be modeled. This is also the approach recommended in the DynamoDB documentation.  AWS Documentation 



What is a partition key?

The partition key is an attribute used by DynamoDB to determine how an item is distributed across partitions. DynamoDB uses the partition-key value as input to an internal hash function to determine the partition.  AWS Documentation 
For example:
PK
TEAM#ARS
TEAM#CHE
TEAM#LIV
Choosing a partition key isn't simply about finding an attribute that identifies the data.
It should also support the way the application needs to access that data.
This helped me understand why partition-key selection is such an important part of DynamoDB data modeling.



What is a sort key?

A sort key can be used together with a partition key to create a composite primary key.
For example:
Partition Key Sort Key
TEAM#ARS MATCH#001
TEAM#ARS MATCH#002
TEAM#ARS MATCH#003
Multiple items can have the same partition-key value while having different sort-key values.
Together, the partition key and sort key uniquely identify an item. Items with the same partition-key value are organized by their sort-key values, which also allows related items to be queried together.  AWS Documentation 
Seeing this relationship in NoSQL Workbench made the concept much easier to understand.



Why does partition-key choice matter?

While learning about partition keys, I also came across the concept of a hot partition.
DynamoDB distributes data and traffic across partitions. If a partition-key design causes a disproportionate amount of traffic to be directed to a particular partition, it can result in a hot partition and inefficient use of available capacity.  AWS Documentation 
This added another consideration to key design.
A partition key needs to support the required access patterns while also helping distribute the workload effectively.
So the question isn't only:
Can I find the data?
It is also:
How will the workload be distributed?



Making the concepts practical

NoSQL Workbench helped connect these concepts to an actual data model.
It provides visual tools for designing DynamoDB data models and working with access patterns, making it easier to see how keys and data fit together.  AWS Documentation 
For me, the important connection became:
Access patterns → Key design → Data model



The key takeaway

The biggest lesson from my first DynamoDB data-modeling experience was to start with how the data needs to be accessed.
Instead of beginning with:
How should I store this data?
start with:
How will I need to retrieve this data?
That change in perspective made concepts such as partition keys and sort keys much easier to understand.
For anyone starting with DynamoDB, this is the principle I found most useful:
Understand the questions your application needs the database to answer before designing the table.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article