Overview of DynamoDB Data Modeling

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) :

  • Optimized for storage with data normalisation
  • Each table has a strict schema.
  • Need more compute power to retrieve data from multiple tables
  • Performance may degrade as the database scales.

NoSQL databases

  • Optimised for compute rather than storage
  • Flexible schema
  • Designed for highly scalable applications

DynamoDB:

  • NoSQL offering from AWS
  • Provides consistent performance at any scale
  • Guarantees millisecond latency for operation
  • Can provide microsecond latency with caching enabled

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:

  • Requires a shift in thinking from relation Rollator modeling
  • Don't emulate a relational model
  • Need to identify the access patterns before table design
  • Most applications need only one table
  • Identify primary keys and indices to minimize the number of requests to dynamoDB to satisfy each access pattern

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:

  • Make use of the flexible schema to store different types of records in the same table
  • Identify the most suitable, hash key and sort key for each type of record to satisfy access patterns
  • Identify secondary indexes for additional access patterns, that cannot only be satisfied by the primary key, (hash and Sort).

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

要查看或添加评论,请登录

Florian GOTO的更多文章

社区洞察

其他会员也浏览了