🌐
AWS
aws.amazon.com › blogs › compute › creating-a-single-table-design-with-amazon-dynamodb
Creating a single-table design with Amazon DynamoDB | Amazon Web Services
July 28, 2021 - In DynamoDB, the adjacency list design pattern enables you to combine multiple SQL-type tables into a single NoSQL table. It has multiple uses but in this case can model many-to-many relationships. To do this, the partition key contains both types of item – races and racers. The key value contains the type of data expected in the item (for example...
🌐
DeBrie Advisory
alexdebrie.com › posts › dynamodb-single-table
The What, Why, and When of Single-Table Design with DynamoDB | DeBrie Advisory
February 5, 2020 - And one of the big benefits of joins is the ability to get multiple, heterogenous items from your database in a single request. In our example above, we want to get both a Customer record and all Orders for the customer. Many developers apply relational design patterns with DynamoDB even though they don't have the relational tools like the join operation. This means they put their items into different tables according to their type.
Discussions

DynamoDB single table design - Stack Overflow
Am I better off with multiple DynamoDB tables to store the info? I would prefer not using scan queries for economic reasons. Ideally I can get all the data via query and scan operation. ... I’m voting to close this question because it's opinion-based and not about programming. ... Here's one single-table option. The design ... More on stackoverflow.com
🌐 stackoverflow.com
Single Table Design - Implementing Multiple Relations

I second the gsi comment. You may want to consider giving each job a unique partition key to avoid hot key throttling.

More on reddit.com
🌐 r/aws
2
1
March 28, 2023
[deleted by user]
The cynic in me says you've used the wrong datastore for the job. This would be trivial and transactional in a relational database, not so much in a document based DB (such is the case with DynamoDB). More on reddit.com
🌐 r/aws
28
12
November 4, 2023
DynamoDB Single Table Deign: Simple Guide To Modeling & Querying On To Many Relationships. (Using Excel to plan out the queries)
One of the things that I hear about single table design is that you need to understand all your access patterns up front. But rarely do requirements come up front. Agile (putting aside the cargo cult) is often executed in a way that reacts to changing demands and this seems to be an admission of flawed requirements, or information that only comes later. With the extra cognitive load of planning a single table design I feel like it’s going to optimise RCU at the cost of refactoring exercises down the track. But I’d be happy to understand opposing points of view. More on reddit.com
🌐 r/aws
12
66
October 3, 2022
🌐
AWS
aws.amazon.com › blogs › database › single-table-vs-multi-table-design-in-amazon-dynamodb
Single-table vs. multi-table design in Amazon DynamoDB | Amazon Web Services
August 16, 2022 - It’s absolutely true that you ... to DynamoDB. But that doesn’t necessarily mean we must use single-table design with materialized joins. We could get most of the same benefits by structuring our tables to fetch both sets of data in parallel, rather than sequentially. Think back to our example above where ...
🌐
DynamoDB
dynobase.dev › dynamodb-single-table-design-examples
DynamoDB Single-Table Design Examples [Interactive Library]
View pre-made DynamoDB single table design models made by experts - use them as reference for your own DynamoDB one-table models and access patterns.
🌐
Emshea
emshea.com › post › part-1-dynamodb-single-table-design
Part 1: Refactoring to single-table design in Amazon DynamoDB
This blog post is Part 1 in a series on refactoring my daily Chinese vocab app to a single-table design in Amazon DynamoDB. In this post, I explain why I chose single-table design, the resources I used to learn it, and walk through the design process and a few example access patterns.
🌐
OneUptime
oneuptime.com › home › blog › how to implement dynamodb single-table design
How to Implement DynamoDB Single-Table Design
January 26, 2026 - The sort key condition is optional but lets you narrow down results efficiently. DynamoDB can only query within a single partition at a time on the base table. The most critical step in single-table design is identifying your access patterns before you design your keys.
🌐
AppSignal
blog.appsignal.com › 2024 › 09 › 18 › dynamodb-single-table-design-with-typescript.html
DynamoDB Single-Table Design with TypeScript | AppSignal Blog
September 18, 2024 - For example, we can fetch all quests for a character by querying the table with the partition key USER#username. The sort key gives us the ability to filter by the prefix QUEST# to fine-tune the query.
🌐
System Design School
systemdesignschool.io › blog › dynamodb-single-table-design
Optimizing Database Performance: Advantages of Using Amazon''s DynamoDB Single Table Design in Serverless Applications
This scenario steps through creating an Amazon DynamoDB table named MusicCollection and adding an item to this table. First, define the access pattern that your application requires. For example, you might want to retrieve User records based on their User partition key.
Find elsewhere
🌐
Medium
medium.com › @rick.osullivan › getting-started-with-dynamodb-single-table-design-53ef9f04340c
Getting Started with DynamoDB single table design | by Rick O'Sullivan | Medium
January 30, 2024 - While it may seem unconventional at first, so lets take a look at the above example transposed it onto a single table design. ... The first thing you might notice is we have a Partition Key (PK) and Sort Key (SK) in our table. We refer to this as a composite key. This composite key is important as it determines how we store our data in the table. More specifically, to read and write data to the table, DynamoDB uses the value of the partition key as input to an internal hash function.
🌐
DevCom
devcom.com › home › articles › tech blog › one approach to aws dynamodb single-table design
One Approach To AWS DynamoDB Single-Table Design | DevCom
May 28, 2026 - In Amazon DynamoDB, single-table ... for each type. For example, instead of having one table for users, another for orders and another for products, we can put all this information into ......
Top answer
1 of 2
1

Here's one single-table option. The design satisfies your access patterns using query operations. No scan operations are required.

pk sk gsi1pk gsi1sk
org#org-1 xInfo
proj#proj-1 xInfo org#org-1 proj#proj-1#xInfo
script#script-1 xInfo proj#proj-1 script#script-1#xInfo
script#script-1 rev#2023-10-05T22:00:00 proj#proj-1 script#script-1#rev#2023-10-05T22:00:00
script#script-1 rev#2023-03-13T10:00:00 proj#proj-1 script#script-1#rev#2023-03-13T10:00:00
script#script-1 rev#2022-12-20T08:00:00 proj#proj-1 script#script-1#rev#2022-12-20T08:00:00
user#user-1 xInfo org#org-1 user#user-1#xInfo
user#user-2 xInfo org#org-1 user#user-1#xInfo

The table primary key models the records. The partition key pk has the format <entity-type>#<entity-id>. I find the entity-type prefix helpful to visually identify a record's entity type, but it is optional here. The sort key sk defines the record type. Scripts have two record types, info and revisions. Giving script revisions a timestamp "id" makes it easy to retrieve all revisions or only the latest revision1. I renamed info to xInfo to move the "info" record after all revisions in lexical ordering2. Why do this? So we can query a script by pk in descending order (ScanIndexForward: false) with a limit of 2 to get a script's info record and latest revision in a single operation. No limit returns all revisions and the info record.

Use the table primary key to answer all the "by id" queries. We need an index to handle the "belongs to" queries.

The secondary index partition key (gsi1pk) models the "belongs to" relation. Organizations appear not to belong to anything, so the index is blank. The index sort key gsi1sk takes the form <entity-type>#<entity-id>#<record-type>. The record-type suffix isn't needed except for scripts, but seems like a good idea to apply everywhere for consistency and future-proofing.

"Get all users belonging to a organization" is answered with a query of gsi1pk = org#org-1 and gsi1sk > "user#". The same pattern satisfies the other "belongs to" queries.

A note on your closing question "Am I better off with multiple dynamodb tables...?": Including multiple tables in your design doesn't give you more modelling options. You are still working with partition and sort keys. Multiple tables may be called for in certain cases, but it doesn't really help with modelling as such.


  1. The timestamp component also gives you the option to query for a subset of revisions by time period (e.g. current year's revisions).

  2. You could use ~info or z instead of xInfo, as long as the prefix character comes after rev in UTF-8 sort order. We do this to engineer a useful script sort key (descending) order: info record, latest revision, latest-1 revision, etc.

2 of 2
0

The pattern you're trying to implement is called EAV (entity-attribute-value).

It has its uses, mainly for multi-tenant databases where the set of entities and their attributes can be set up and changed at run-time.

For instance, on an online shopping platform, a vendor can set up a set on attributes just for the washing machines (load type, number of cycles, energy efficiency etc.), and add and remove the attributes as they see fit, without changing the database layout.

It's a pain to index and query data laid out like that, so this kind of model is a necessary evil for certain use cases, of which yours isn't one.

I think design recommendations are off-topic for this side, as they are naturally too wide and opinion-based. So I'll point out a couple of more concrete problems with your design as this is something can be objectively addressed.

Hot partitions

Putting a hardcoded resource type id as a partition key for your GSI will make all the records go into a single partition, which will become a "hot partition" in DynamoDB parlance.

Every time you add, say, a script revision, Dynamo will have to add an entry to the GSI on (type, parent), which will go to the single partition storing the PK value script_partition

DynamoDB recommendations explicitly spell it out:

Status code, where there are only a few possible status codes: Bad

Lack of natural ordering

Your revisions are keyed as rev_1, rev_2 and rev_latest. rev_10, in the sorting order, will come between rev_1 and rev_2. You will either to always pull all the revisions and sort them on the client, or add and index an extra field with the revision date, filled out only for the revisions. If you do the latter, why not do all the way and just create a separate table?

Extra updates

Every time you add a new revision, you will need to update the previous rev_latest to rev_xxx, and you will only know what xxx is after a full sort (or querying a secondary index). This will also be prone to race conditions.

🌐
Medium
medium.com › @QuinnMil › dynamodb-single-table-design-d60be6aa2298
DynamoDB Single Table Design. Getting the most out of Amazon… | by Quinn Milionis | Medium
June 22, 2023 - This example demonstrates a straightforward representation of a one-to-many relationship in DynamoDB. This is the essence of Single Table design” — using a single table to represent multiple record types and their relationships without the need for complex joins.
🌐
DEV Community
dev.to › aws-builders › single-table-design-in-aws-dynamodb-ld8
Single Table Design in AWS DynamoDB - DEV Community
August 31, 2024 - By designing your PK and SK to support your querying patterns, you can retrieve related items using a single query. This eliminates the need for costly table scans and reduces the amount of throughput consumed. ... Storing related entities in a single table can help reduce storage costs compared to storing them in separate tables. DynamoDB charges based on the amount of data stored, so minimizing data duplication across tables can lead to cost savings.
🌐
Medium
arunrajeevan.medium.com › single-table-design-aws-dynamodb-cffd230a371f
Single Table Design — AWS DynamoDB | by Arun Rajeevan | Medium
January 29, 2024 - In the example below, we have a DynamoDB table that contains actors and the movies in which they have played. The primary key is a composite primary key where the partition key is the actor’s name and the sort key is the movie name.
🌐
DataCamp
datacamp.com › tutorial › single-table-database-design-with-dynamodb
Performance and Scalability Unleashed: Mastering Single Table Database Design with DynamoDB | DataCamp
September 7, 2023 - This final example shows a customer’s order history with two products made from two different order IDs. For those interested in how data modeling works in SQL databases, our Data Modeling in SQL webinar offers valuable insights that can complement your understanding of NoSQL data modeling. Using a single table design with DynamoDB ...
🌐
Momento
gomomento.com › home › single table design for dynamodb: the reality
Single table design for DynamoDB: The reality - Momento
June 7, 2024 - Denormalizing in DynamoDB data modeling produced the bonus effect of having less total tables than a standard third normal form pattern. Back when single table design was first being marketed, there was no auto scaling, no on-demand, no adaptive capacity – each table meant more operational burden.
🌐
AWS
docs.aws.amazon.com › amazon dynamodb › developer guide › data modeling for dynamodb tables › data modeling foundations in dynamodb
Data Modeling foundations in DynamoDB - Amazon DynamoDB
Explore the foundations of data modeling in DynamoDB, examining the advantages and disadvantages of single table and multiple table design patterns to optimize data access, performance, and cost.
🌐
DEV Community
dev.to › urielbitton › advanced-single-table-design-patterns-with-dynamodb-4g26
Advanced Single Table Design Patterns With DynamoDB - DEV Community
January 7, 2025 - Well, with the single table design, we can model the data for multiple data entities and overload our primary keys to store these entities together. Here’s an example.
🌐
Tinybird
tinybird.co › docs › forward › get-data-in › guides › ingest-from-dynamodb-single-table-design
Working with DynamoDB Single-Table Design · Tinybird Docs
July 28, 2025 - Single-Table Design is a common pattern recommended by AWS in which different table schemas are stored in the same table. Single-table design makes it easier to support many-to-many relationships and avoid the need for JOINs, which DynamoDB doesn't support.
🌐
Serverless Life
serverlesslife.com › DynamoDB_Design_Patterns_for_Single_Table_Design.html
Serverless Life | DynamoDB Design Patterns for Single Table Design
November 7, 2020 - For example, for the user, use username or email, not some random ID. This way, you take advantage of the primary index, which otherwise would be unused. Principals of #DynamoDB #singletabledesign: one table, reuse keys and secondary indexes, ...