AWS Builder Center

Why Your Database Design Matters More in DynamoDB Than You Think

DynamoDB requires a different mindset from relational databases. This article explains access-pattern-first design, partition and sort keys, denormalization, single-table design, GSIs, and when DynamoDB is—or isn't—the right choice.

When developers first encounter Amazon DynamoDB, one of the easiest mistakes to make is to think of it as a traditional relational database without SQL.
Coming from databases such as MySQL or PostgreSQL, we are usually taught to start by designing tables, defining relationships, normalizing data, and then writing queries.
DynamoDB requires a different way of thinking.
Instead of starting with the question “How should I structure my tables?”, a better starting point is:
“How will my application access this data?”
This idea, often called access-pattern-first design, is one of the most important concepts to understand when working with DynamoDB.

A Simple Example

Imagine we're building an online shopping application.
We might have information about users, products, and orders.
In a relational database, we could create separate tables for users, products, and orders and connect them using relationships.
That approach works extremely well for many applications.
With DynamoDB, however, we should first think about the operations our application actually needs.
For example:
  • Get a customer's details using their user ID
  • Find all orders belonging to a customer
  • Get a particular order
  • Find all products belonging to a category
These are our access patterns.
Once we know them, we can design the DynamoDB table around those operations.

Why This Is Different From MySQL

In a relational database, we might write a query such as:
1
2
SELECT * FROM orders
WHERE customer_id = 101;
The database is designed to support flexible querying across related tables.
DynamoDB works differently.
Its primary key structure is extremely important because it determines how data can be efficiently retrieved.
Instead of designing a database and then asking DynamoDB to perform arbitrary queries against it, we should design the data model around the queries our application needs to perform.
This is one reason DynamoDB can feel unusual at first for developers who are used to relational databases.

Partition Key and Sort Key

A DynamoDB table can use a partition key, and it can optionally have a sort key.
The partition key determines how DynamoDB distributes items, while the sort key can organize related items under the same partition key.
For example, imagine storing customer orders.
We could use a customer ID as the partition key and an order ID or timestamp as the sort key.
That allows the application to efficiently retrieve orders associated with a particular customer.
The exact key design depends on the application's access patterns.
This is why choosing keys isn't simply a database configuration step. It is part of the application's architecture.

The Interesting Part: One Table Can Store Different Types of Data

Another concept that can surprise SQL developers is that DynamoDB doesn't require every item in a table to represent exactly the same kind of entity.
A single table can contain different item types if the key design supports the application's access patterns.
For example, the same table could contain customer and order information, with carefully designed partition and sort keys allowing related data to be retrieved efficiently.
This approach is commonly associated with single-table design.
It can reduce the need for joins because related information can be stored in a way that makes the required access pattern efficient.
But single-table design shouldn't be treated as a rule that every DynamoDB application must follow.
The correct design depends on the workload and the queries the application needs to support.

Why Joins Change the Way You Think

Suppose we have:
Customers
customer_idname
101Alex
and:
Orders
order_idcustomer_idamount
5001101₹1200
5002101₹800
In MySQL, joining these tables is straightforward.
In DynamoDB, we don't have traditional relational joins.
Instead, we might design the data so that the information needed together can be retrieved efficiently from the same access pattern.
This can mean duplicating some data.
At first, that may feel wrong if you've been taught that normalization is always the goal.
But DynamoDB intentionally allows a different trade-off:
Sometimes duplicating data is better than performing expensive or unavailable joins.
The important thing is to understand why the duplication exists and how the application will maintain consistency.

Denormalization Isn't Automatically Bad

In relational database design, normalization helps reduce redundant data and update anomalies.
DynamoDB often uses denormalization because the database is optimized around known access patterns.
For example, suppose an order frequently needs to display the customer's name.
Instead of requiring another lookup every time the order is displayed, the customer's name could potentially be stored with the order data.
Now the application can retrieve the information it needs in a single operation.
The trade-off is that if the customer's name changes, duplicated values may also need to be updated.
This is a classic example of choosing between read efficiency and update complexity.

What Happens If You Design the Table First?

This is where many beginners run into problems.
Imagine creating a DynamoDB table with a simple structure because it "looks clean."
Later, the application requires a query that wasn't considered during the original design.
You may discover that the required query isn't efficient with the existing key structure.
You might then need to introduce a Global Secondary Index, change how data is stored, or redesign the table.
This is why DynamoDB design should begin with the application's requirements rather than the database schema alone.

Global Secondary Indexes

A Global Secondary Index (GSI) provides another way to query items using a different key structure from the table's primary key.
For example, suppose the main table is optimized for retrieving orders by customer.
Later, the application also needs to retrieve orders by product.
A GSI can potentially provide an additional access pattern without changing the primary key of the table.
But indexes aren't free design decisions.
They consume additional resources and can increase storage and write costs, so they should be introduced because the application needs them rather than simply adding indexes for every possible query.

When DynamoDB Is a Good Choice

DynamoDB can be particularly useful for applications that require predictable, low-latency access at scale.
Examples include:
  • Shopping carts
  • Gaming applications
  • User sessions
  • IoT workloads
  • Event-driven applications
  • User profiles
  • High-volume application backends
AWS also provides DynamoDB integration with Lambda and API Gateway, making it a common component in serverless architectures.
However, DynamoDB isn't automatically the best database for every application.
If an application needs complex joins, flexible ad-hoc queries, or strongly relational data modelling, a relational database may be a better fit.
Choosing a database should depend on the application's requirements rather than simply choosing the technology that happens to be popular.

The Main Lesson

The biggest change in mindset for me is this:
With a relational database, we often start with the data model and then think about queries.
With DynamoDB, we should start by understanding the access patterns and then design the data model around them.
That doesn't mean DynamoDB is better than relational databases.
It means the two database models optimize for different kinds of workloads.
Understanding that difference is much more valuable than simply memorizing DynamoDB terminology.

Final Thoughts

If you're learning AWS as a developer, DynamoDB is worth understanding because it introduces a different approach to database design.
The most useful question isn't:
“How do I convert my MySQL tables into DynamoDB?”
It's:
“What does my application need to read and write, and how should I structure the data to make those operations efficient?”
Once you start thinking in terms of access patterns, partition keys, sort keys, indexes, and intentional denormalization, DynamoDB starts to make much more sense.
For developers coming from MySQL or PostgreSQL, what DynamoDB concept was the hardest to understand at first?
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