Concepts / Entity-Relationship Models

Entity-Relationship Models

Crow's Foot Diagrams use boxes to represent tables and lines with notation symbols to represent relationships between tables.

  • Programming
Interactive lab

Try it: From an ER Diagram to Tables

How the cardinality on an entity-relationship diagram decides the schema: each entity becomes a table with a primary key, a one-to-many relationship puts the foreign key on the many side, and a many-to-many relationship needs a junction table — and how sample rows that do not fit a too-narrow cardinality are rejected.

How it works

  1. Ask the cardinality question from both sides: can one row here link to many rows there, and the other way round? Many on both sides is many-to-many.
  2. Each entity becomes a table with an INTEGER PRIMARY KEY id.
  3. One-to-many: the many side gets a foreign-key column referencing the one side's primary key. One-to-one: that foreign key is also UNIQUE.
  4. Many-to-many: one foreign-key column holds one value per row, so a junction table with a foreign key to each side (and a composite primary key) stores every pairing — two one-to-many relationships.
  5. Load the sample rows: a second link for the same row would need a second row with the same id, so SQLite rejects it (UNIQUE constraint failed); junction rows always fit.

Default run (17 steps): Model: Customer, Order, Product with Customer places Order (1:N) and Order contains Product (M:N). … Every active link is stored: the schema produced by the mapping rules can hold these rows.

Simplified: A toy relational engine in the browser, not SQLite itself: statements are built from the controls (no SQL text is parsed or executed) and tables have a few rows. Results were checked against Python's sqlite3 (SQLite 3.49). Three entities with one text attribute each and two relationships; participation (optional vs mandatory) is not modelled, so foreign keys allow NULL. The one-to-one rule (UNIQUE foreign key on the second entity) is the common textbook mapping.

Educational simulation

Loading the simulation…

From Tables to a Visible Model

A database with two tables and one relationship may be easy to understand from a short description. Real-world databases can contain dozens or even hundreds of tables with complex interconnections. At that size, trying to keep every relationship in your head becomes impractical. A graphical data model turns the abstract structure into something you can see and reason about at a glance.

An Entity-Relationship Model represents database structure visually. In a Crow's Foot Diagram, each table appears as a box, and relationships appear as lines connecting the boxes. Symbols at the ends of those lines describe how many records may be related and whether the relationship is optional or mandatory.

Tablesnames and columnsVisible data modelstructure at a glanceRelationship linesconnectionsNotation symbolscardinality and optionalityshow entitiesshow connectionsshow constraints
How does a visual model make connected database tables easier to reason about than a relationship description alone?

Anatomy of a Crow's Foot Diagram

A table box is a rectangle divided into sections. Its top section contains the table name. The sections below list the table's columns. A primary key is typically marked with a symbol such as PK or an asterisk. A foreign key is often marked with FK or a dagger symbol. These markings help identify which columns establish relationships.

A relationship line connects two table boxes through key columns. The primary key on one side links to the foreign key on the other side. This makes the dependency visible: a foreign key in the Track table can reference a primary key in the Artist table, showing which artist created which track.

Artisttable boxArtist PKprimary keyTrack FKforeign keyTracktable boxRelationship linetable connectioncontainscontainsconnectsconnects
What does each table box, key column, and connecting line represent in a Crow's Foot Diagram?

Reading the Endpoint Symbols

The symbols at each end of a relationship line communicate two separate ideas. Cardinality describes how many records may be associated: a single dash represents one, while a crow's foot represents many. Optionality describes whether the association is required: a perpendicular dash represents mandatory, while a circle represents optional.

Endpoint combinationCardinalityOptionalityMeaning
Single dash with perpendicular dashOneMandatoryExactly one record is required
Single dash with circleOneOptionalZero or one record is allowed
Crow's foot with perpendicular dashManyMandatoryMany records are required
Crow's foot with circleManyOptionalZero or many records are allowed

The four endpoint configurations described in the source material.

Single dashcardinality: onePerpendicular dashoptionality: mandatoryExactly oneone plus mandatoryCrow's footcardinality: manyCircleoptionality: optionalZero or oneone plus optionalMany requiredmany plus mandatoryZero or manymany plus optionalwith perpendicular dashwith circlewith perpendicular dashwith circle
How do a crow's foot, circle, and dash combine to show cardinality and optionality at one end of a relationship line?

Tracing Both Ends of a Relationship

Never interpret only one end of a relationship line. Read the symbols attached to the table on one side, then read the symbols attached to the table on the other side. Each endpoint is interpreted from the perspective of the table to which it is attached. Together, the two endpoints describe the relationship between the tables.

The three fundamental relationship types are one-to-one, one-to-many, and many-to-many. Their notation patterns become recognizable by comparing the cardinality symbols at the two ends. The optionality symbols add a second layer: they tell you whether the relationship can be absent or must exist.

Table Aone sideOne or manyread at Table ARelationship typeone-to-one, one-to-many, ormany-to-manyTable Bother sideOne or manyread at Table Battached symbolsattached symbolscombinecombine
What does each end of a relationship line contribute to your interpretation of how many records may be associated?

What do you think happens?

Before naming the relationship type, what should you inspect?

  • Only the table names

  • Only the foreign-key column

  • The notation symbols at both ends of the relationship line

  • Only the symbol closest to the first table

Reveal answer
Answer:

The notation symbols at both ends of the relationship line

Each endpoint contributes information about cardinality and optionality. The complete relationship cannot be interpreted from one end alone.

Artist and Track Worked Example

Worked example

Following a Key-Based Connection

Explain the visible connection between the Artist table and the Track table in the source example.

  1. 1
    Locate the table boxes

    Identify the Artist table and the Track table in the diagram.

  2. 2
    Locate the key columns

    The Artist table contains the primary key used on its side of the relationship. The Track table contains a foreign key used to reference that primary key.

  3. 3
    Follow the relationship line

    The line connects through the key columns, making the dependency between the two tables visible.

  4. 4
    Interpret the domain connection

    The relationship expresses which artist created which track.

Result

The diagram communicates the Artist-to-Track connection by linking the Artist primary key to the Track foreign key.

ArtisttableArtist PKprimary keyTrack FKforeign keyRelationship linekey-column connectionTracktablecontainscontainslinkslinks
How do table boxes and key columns become a connected relationship in a Crow's Foot Diagram?

Constructing a Diagram

  1. 1
    Identify the tables that participate in the relationship.
  2. 2
    Draw one table box for each table, including its table name and columns.
  3. 3
    Mark the primary key and foreign key columns using the notation used by the diagram.
  4. 4
    Connect the related key columns with a relationship line.
  5. 5
    Place the cardinality symbol at each end: a single dash for one or a crow's foot for many.
  6. 6
    Place the optionality symbol at each end: a perpendicular dash for mandatory or a circle for optional.
  7. 7
    Read the completed line from both table perspectives to check that the relationship type and constraints are represented.

Construction is a two-part task. First, represent the structural objects: table boxes, table names, columns, primary keys, and foreign keys. Second, represent the relationship rules: connect the key columns and annotate both ends of the line with cardinality and optionality symbols.

Common Reading Mistakes

  • Common mistake

    Reading only one end of the relationship line

    What it looks like

    A learner notices a crow's foot beside one table and stops interpreting.

    Why it fails

    The symbols at both ends are needed to determine the complete relationship.

    Do this instead

    Inspect each endpoint from the perspective of the table to which it is attached.

  • Common mistake

    Treating a crow's foot as the entire meaning of the endpoint

    What it looks like

    A learner sees many and ignores the circle or perpendicular dash beside it.

    Why it fails

    Cardinality and optionality are separate pieces of information.

    Do this instead

    Read the crow's foot or single dash for cardinality, then read the circle or perpendicular dash for optionality.

  • Common mistake

    Confusing optional with mandatory

    What it looks like

    A circle is interpreted as a required relationship.

    Why it fails

    The circle indicates that the relationship is optional.

    Do this instead

    Remember that a circle means optional, while a perpendicular dash means mandatory.

  • Common mistake

    Ignoring key columns

    What it looks like

    A line is drawn between table boxes without identifying the related columns.

    Why it fails

    The relationship is established through a primary key on one side and a foreign key on the other.

    Do this instead

    Connect the relationship through the relevant key columns.

Practice Reading Symbols

MEDIUM

Practice task: For each endpoint configuration in the notation table, state the cardinality, the optionality, and the complete meaning. Then explain why interpreting both ends of a relationship line is necessary for identifying whether the relationship is one-to-one, one-to-many, or many-to-many.

Hints
  • Separate the cardinality symbol from the optionality symbol.
  • A single dash means one; a crow's foot means many.
  • A perpendicular dash means mandatory; a circle means optional.
  • Apply the interpretation from the perspective of the table attached to that endpoint.

Key Takeaways

  1. 1
    Crow's Foot Diagrams make complex database structures visible by representing tables as boxes and relationships as annotated lines.
  2. 2
    Table boxes contain table names and columns; primary keys and foreign keys identify the columns that establish relationships.
  3. 3
    Cardinality uses a single dash for one and a crow's foot for many.
  4. 4
    Optionality uses a perpendicular dash for mandatory and a circle for optional.
  5. 5
    A complete interpretation requires reading the notation at both ends of every relationship line.

At a glance

  • A Crow's Foot Diagram turns a complex collection of database tables and relationships into a visual model.
  • Boxes represent tables, while lines connect related key columns.
  • Single dashes and crow's feet communicate one-versus-many cardinality.
  • Perpendicular dashes and circles communicate mandatory-versus-optional relationships.
  • Both ends of a relationship line must be read together to understand the complete relationship.

Related concepts

More concepts starting with E