šŸ”— Learn

Entity Relationship Diagrams

What is an ERD?

ERDs show how tables relate to each other

An Entity Relationship Diagram (ERD) is a visual blueprint of a database.

  • An entity is any type of object we store data about — shown as a rectangle (box). In a relational database, each entity becomes a table.
  • A relationship is a link between two entities — shown as a line connecting their boxes.
  • Cardinality numbers (1, M, N) at each end of a line tell you *how many* instances can exist on that side.
  • ERDs are drawn *before* coding the database so designers can agree on the structure without writing a single line of SQL.

    A simple ERD — Students and Grades

    Students Grades 1 M ↑ entity (table) ↑ entity (table) ↑ relationship

    The "1" and "M" show cardinality: one student can have many grades