Is there diagram for dynamoDB schema like ER diagram for RDBMS?

Viewed 2441

I'd like to write documentations of my dynamodb schema.

Is there some diagram for document or should I use ER diagram?

2 Answers

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.

I love Alex's book.

I use PlantUML in my documentation generation, which is available online via Planttext. The big benefit for me is that you do the diagram in plain text so it diffs wonderfully, checked in alongside source.

PlantUML has a standard ERD syntax which is an extension of their OO class diagrams. I've abused it slightly in the example below to include some subclassing relationships.

Content store to back a mobile app

@startuml

title Touchgram Content Store

entity Artist {
* Name
* Bio
UsualLicense
}


entity PhysicalGallery {
* Name
* Address
* Contact
Description
}

entity OnlineGallery {
* Name
* WebAddress
Description
}


entity PhysicalProduct {
* Name
Description
}

entity DigitalSale {
* Price
* Timestamp
}
note bottom of DigitalSale : All digital sales\nare totally anonymous\nvia online credit

entity DigitalProduct {
* Name
* DownloadFile
* Price
License
}

entity DigitalAvail {
* Price
* DateRange
Comments
}

Artist }o..|| DigitalProduct
DigitalProduct }o..|| DigitalSale
DigitalProduct }o..|| DigitalAvail
DigitalProduct }o..|{ PhysicalProduct
DigitalProduct <|-- Image
DigitalProduct <|-- Sound
DigitalProduct <|-- VisualEffect
DigitalProduct <|-- Template

Template }o..o{ DigitalProduct : "Uses Other\nProduct"
note bottom of Template : Template Touchgrams\n(eg: greeting cards or memes)\nCan use digital products\nfrom many artists\nso license & sales would\ncascade through

note bottom of DigitalAvail : By default, available\nas soon as in store\nbut restrictions can be added
Artist }o..o{ PhysicalGallery : Exhibits at
Artist }o..o{ OnlineGallery : Advertises
OnlineGallery }o..o{ PhysicalGallery : Advertises
PhysicalProduct }o..o{ OnlineGallery : Sold through
PhysicalProduct }o..o{ PhysicalGallery : Shown at

note "Normally one digital version\nwould exist of a canvas\nbut often offer prints\n\nconversely, more rarely\nmight do several digital\nversions of a work\neg: with different filters\nor even crop portions\n\nWe **do not** handle\nphysical sales" as N1
N1 .. PhysicalProduct
@enduml
Related