Search⌘ K

Table Best Practices

Explore how to design DynamoDB tables for optimal speed by mastering single-table design, effective partition key selection, and using sort keys to model relationships. Understand how to prevent hot partitions and employ write sharding to distribute traffic evenly. This lesson equips you with practical strategies for building efficient and scalable DynamoDB data models.

Single-table design

There is a difference between how we model data in SQL databases and how we model data in DynamoDB. In SQL databases the primary concern is to save space and provide query flexibility. In DynamoDB we are primarily concerned about speed.

Let’s take the example of a shopping cart. There are users and orders. One user can be associated with multiple orders. In a SQL-based design, there are two tables, like the ones illustrated below.

However, when we design the same data for DynamoDB, we will use a single table with user_id as the ...