AWS Amplify - AppSync & Multiple DynamoDB Tables

As you mentioned, the DynamoDB documentation suggests that “most well designed applications only require a single table”. This is valid for many applications when developers have learned, over the course of time, their data access patterns, settled on a data model, and have certain scale requirements that need to be optimized. Many developers do not have this level of understanding of their application from day 1 or necessarily the same requirements. Additionally some of the points mentioned in the presentations on single table design (e.g. tradeoffs between storage costs vs compute) can be subjective based on your application.

When you are building a new app or do not know your data access pattern, the benefits of using the single table design pattern has diminishing results and the multiple tables strategy is much more flexible.

AWS amplify is an opinionated client framework providing sensible defaults for developers who have different levels of scale and complexity, as such it has adopted a multiple table strategy when leveraging the @model transformer in its most basic form. As your requirements evolve, you can augment this design by using additional features of the Transformer such as @key (for creating single table indexes and composite keys) or even full text search & streaming from DynamoDB with @searchable.

We do recognize that large scale or mature apps might benefit of a single table approach. Going from multiple tables to single table is probably a one time “merge” operation, after the prototyping phase, and when data access patterns have been understood by the developer. In reality there is not a “one size fits all approach” which is why Amplify’s GraphQL Transformer gives you different levels of flexibility depending on where your app is at in its evolution.

As Luis mentioned in another answer: AWS AppSync does support any type of table structure independent of the GraphQL Transformer generation pattern. Even if you do have more than one table, you can easily implement GraphQL relational patterns in a single client request either with schema design, nested resolvers, or even implementing Pipeline resolvers.

(this response was redacted with the help of Richard)


Is it truly the case that when using AppSync each type belongs in a separate DynamoDB table?

No, you can use a single table to store different types (or entities) required for your service. As long as you have well defined access patterns for the data you will be using in your service, you may get away with only using one table. However, this approach might be a bit inflexible since you have to think about your access patterns beforehand and might be hard do add new ones in the future.

There is currently no way of taking advantage of the @model directive in Amplify to have such configuration. You will have to manually create the table and then set up your resolvers accordingly for each Appsync type to query/mutate accordingly.

This is a good article that explains the approach: From relational DB to single DynamoDB table: a step-by-step exploration