DevTools Logo

ER Diagrams & Data Modeling Cheat Sheet

Entity-relationship notation (crow's foot, Chen), cardinality, keys, normalization, and schema design patterns.

Databases
er-diagram
data-modeling
database

An entity-relationship diagram maps the things a system stores (entities), their properties (attributes), and how they connect (relationships). A clear ER model precedes a clean relational schema.

Core concepts

Table
ConceptMeaning
EntityA thing with identity (e.g. Customer).
AttributeA property of an entity (e.g. email).
Primary key (PK)Uniquely identifies a row.
Foreign key (FK)References another table's PK.
RelationshipA link between entities (e.g. places).
CardinalityHow many on each side (1:1, 1:N, N:M).

Cardinality (crow's foot)

Table
NotationMeaning
1 ─── 1One-to-one.
1 ───<One-to-many (one customer, many orders).
>───<Many-to-many (students ↔ courses).
0..1Optional (zero or one).
1..*One or more.

Resolving many-to-many

A many-to-many relationship becomes a junction (associative) table holding two foreign keys.

sql
CREATE TABLE enrollment (
  student_id INT REFERENCES student(id),
  course_id  INT REFERENCES course(id),
  PRIMARY KEY (student_id, course_id)
);

Normalization

Table
FormRule
1NFAtomic values; no repeating groups.
2NF1NF + no partial dependency on a composite key.
3NF2NF + no transitive dependency (non-key → non-key).
BCNFEvery determinant is a candidate key.

Design patterns

Table
PatternWhen to use
Junction tableMany-to-many.
Self-referenceHierarchies (manager → employees).
Soft deletePreserve history with deleted_at.
Audit columnscreated_at, updated_at on every table.
Polymorphic FKOne column referencing multiple tables (use sparingly).

References

Related tools