4.4.23 · D1Databases

Foundations — ER diagrams — entities, attributes, relationships, cardinality

1,791 words8 min readBack to topic

Before you can read the parent note, you need to earn every shape, letter and symbol it throws at you. This page introduces them one at a time, from absolute zero — plain words first, then the picture, then why the topic can't live without it.


1. A "thing" — the entity (the rectangle)

Why the topic needs it: your whole database is built out of these boxes. If you can't name the things, you have nothing to store. Everything else (facts, links, counts) hangs off these boxes.

Figure — ER diagrams — entities, attributes, relationships, cardinality

A single specific thing — student "Asha", id 7 — is one instance (one filled-in copy of the box). All students together form the entity set (the whole stack of copies). Keep this three-level idea in your head: type (Student) → set (all students) → instance (Asha).


2. A "fact about a thing" — the attribute (the oval)

Why the topic needs it: a box named Student with nothing inside is useless. Attributes are what you actually store. The parent note spends a whole section on the different flavours of attribute, so let us define each flavour's picture now.

Figure — ER diagrams — entities, attributes, relationships, cardinality

The key attribute deserves special attention because the whole idea of tables (Primary keys and Foreign keys) rests on it.


Why the topic needs it: boxes on their own are isolated islands. Real data is about connections — who owns what, who belongs where. The diamond captures those verbs so you can later turn them into foreign keys and joins.

Figure — ER diagrams — entities, attributes, relationships, cardinality

4. Counting things — the "how many" symbols

Now come the mathematical symbols the parent note uses when it talks about cardinality. Each one is tiny; we build them from zero.

4a. Absolute value bars around a set:

Why this tool and not another: we need a compact way to say "the size of a group". Words like "the number of students" get long fast; the bars are the standard shorthand for size of a collection. (They also mean "distance from zero" for ordinary numbers, but here every entry is a thing, so it can only mean count.)

4b. The multiplication sign for pairing:

Figure — ER diagrams — entities, attributes, relationships, cardinality

4c. The sign and : bounding the count

Why these tools: cardinality is about limits, not exact totals. The pair and are exactly the vocabulary of "no more than" and "the tighter of two limits" — precisely the questions cardinality asks.

4d. The ratio names: 1:1, 1:N, N:1, M:N

Why two different letters: if the note wrote N:N you might think both sides have the same count. Using M and N deliberately says "these two 'many's are unrelated numbers." This distinction is what forces a junction table later.


5. Total vs partial participation — solid vs double line

Why the topic needs it, separate from cardinality: cardinality answers how many (the max), participation answers whether it is mandatory (the min). They are two independent knobs — the parent note's Mistake 4 is confusing them. Keep them apart: count vs must-you.


How these foundations feed the topic

Entity = rectangle

Relationship = diamond

Attribute = ellipse

Key = underlined attribute

Foreign key placement

Count of a set = size bars

Pairs = size times size

Cardinality ratios 1 to 1, 1 to N, M to N

Participation total or partial

Translate ER to tables

Read it top-down: boxes and their key facts define what exists; the counting symbols let you bound the links; ratios plus participation fully describe a relationship; and that determines where the foreign key lives when you finally build tables in SQL CREATE TABLE and constraints.


Equipment checklist

Cover the right side and check you can answer each before reading the parent note.

What shape holds a thing you store data about?
A rectangle (entity)
What shape holds a fact about one thing?
An ellipse/oval (attribute)
What shape holds a link/verb between two things?
A diamond (relationship)
How is the unique-identifier attribute drawn?
Underlined (key attribute)
How is a multivalued attribute drawn?
Double-outlined oval
How is a derived attribute drawn?
Dashed oval
What does mean?
The number of instances (the size) of entity set
Why does count all possible pairs?
It is the area of an -by- grid; each cell is one pair (rule of product)
What does say in words?
The real number of links is at most (a ceiling, not an exact count)
What does pick?
The smaller of the two set sizes
Why use two letters M and N in M:N?
To signal the two "many" counts are independent (need not be equal)
Cardinality answers which question, participation which?
Cardinality = how many (max); participation = is it mandatory (min)
Single line vs double line on a diamond edge?
Single = partial (optional); double = total (mandatory)