Overview of DynamoDB Data Modeling
DynamoDB is the serverless offering of AWS for NoSQL (other AWS services also support NoSQL).
A common mistake when beginning with DynamoDB is to simulate relational data modeling patterns which ends up in larger bills at the end of the month.
DynamoDB is designed to give you low latency at any scale. You must carefully think about your data models in the context of DynamoDB before implementing them.
Data Modeling
Basically, data modeling is about how an application stores data in a given database in relation to the real-world entities of the business.
There are two main types of databases, relational and NoSQL.
Relational databases (MySQL, PostgreSQL, AWS RDS) :
NoSQL databases
DynamoDB:
领英推荐
DynamoDB Data Modeling
When designing data models with dynamoDB, you should forget your previous knowledge about relational database modelling. You should spend as much time as necessary to identify every data access pattern of your application. It is very important to identify at least the most common data access patterns before designing your models.
To sum up:
You will usually store all the data in a single dynamoDB table for efficient queries. This is a departure from relational data modelling which generally requires multiple tables in a database.
One table for the entire application means:
The five steps process when designing dynamoDB data models
1) Draw an entity diagram
2) Identify the relationships between entities (1:1, 1:n, n:n)
3) List down all the access patterns for each entity
4) Identify the primary key (Hash + Sort) for each entity
5) Identify the secondary indexes for additional access patterns if required