Question:
I’d like to write documentations of my dynamodb schema.
Is there some diagram for document or should I use ER diagram?
Answer:
I think it’s a good practice to define an ER diagram. You will establish the entities and their relationship to one another in a DB agnostic way.
While you are at it, I’d suggest creating a document that lists:
- Access Patterns – For example, fetch users by email, fetch orders by status, etc.
- Describe your primary key structure – What are you Primary Key(PK) and Sort Key(SK) patterns? For example PK ORDER# defines the Order entity, USER#<email_address> defines the USER entity, etc.
- Describe any secondary indexes (PK/SK patterns)
Check out how Alex DeBrie models his examples in his AWS talk for a good example.
ER diagrams are a fantastic reference to understand the data model, and I think every database should have one as a part of it’s documentation. With DynamoDB, understanding the access patterns and how the Primary Keys are designed to support the access patterns is critical information.