Data modeling reference

A practical ER diagram reference.

Learn how entities, fields, keys, and cardinality describe a relational data model. Then use the free ER designer to draw the model and export Mermaid that stays reviewable in your repository.

Read the Mermaid ER diagram guide
01Entities & fields

Model the things the application needs to remember.

An entity represents one durable concept: a user, project, invoice, or order. Its fields record the facts that belong to that concept and give each fact a concrete type.

Project

iduuid PKnamestringcreatedAttimestamp
One concept
Keep each entity focused on one recognizable subject.
Stable identity
Give every row a primary key that does not depend on display text.
Useful types
Choose types that preserve the meaning and constraints of each value.

Free · No signup · Mermaid export

Model your entities
02Keys & ownership

Use keys to make every relationship explicit.

A primary key identifies the row. A foreign key points to another row. A unique key prevents duplicates. Together, those constraints turn an arrow into a relationship the database can enforce.

PK

Identity

id

FK

Reference

projectId

UK

Unique

slug

PK
One stable value identifies each record inside its entity.
FK
The child stores the parent key in a field with the same type.
UK
Uniqueness expresses a rule such as one profile per user.

Free · No signup · Mermaid export

Add keys and relations
03Cardinality

Say how many records can exist on either side.

Cardinality distinguishes one-to-one from one-to-many and many-to-many. The notation is compact, but it carries an important product rule about ownership and repetition.

User|| — ||Profile
Project|| — o{Task
1–1
One record pairs with at most one record on the other side.
1–N
One parent can own many children; each child points to one parent.
Direction
Draw from parent to child so the foreign key lands where it belongs.

Free · No signup · Mermaid export

Draw a relationship
04Many-to-many

Resolve many-to-many with a junction entity.

A relational database cannot store a many-to-many link as one foreign key. A junction entity turns it into two one-to-many relationships and gives the relationship room for its own fields.

User1:NMembershipuserId + teamIdN:1Team
Two foreign keys
The junction points to one record from each parent entity.
One pair
A composite unique rule can prevent the same pair from appearing twice.
Relationship data
Role, quantity, or joined-at timestamps belong on the junction.

Free · No signup · Mermaid export

Create a junction entity
05Mermaid export

Keep the diagram reviewable beside the code.

Mermaid stores the diagram as text. It renders on GitHub and documentation sites, survives ordinary code review, and changes in a diff instead of becoming another stale screenshot.

erDiagram
  PROJECT {
    uuid id PK
    string name
  }
  TASK {
    uuid id PK
    uuid projectId FK
  }
  PROJECT ||--o{ TASK : "projectId"
Typed fields
Attribute rows retain their field names, types, and key markers.
Crow’s foot
Relationship arrows preserve one-to-one and one-to-many cardinality.
Portable text
The same .mmd file can live in a README, docs site, or editor.

Free · No signup · Mermaid export

Export a Mermaid diagram

Put the model to work

Connect the data model to a complete React project.

In Nodlume, the same entities ground generated types, API routes, test cases, and project documentation beside the rest of the application plan.

Start planning free

We'd like to use Google cookies to understand how Nodlume is used and to measure our advertising. Nothing loads until you choose, and declining does not affect anything in the app.