This guide shows the four relationship patterns you will meet in almost every database: one-to-one, one-to-many, many-to-many (resolved with a junction table), and optional relationships. Each is drawn in crow's foot notation next to the plain-English rule and the SQL that enforces it.
1. The Diagram
Each row shows one pattern, the business sentence it encodes, and how it is enforced in SQL.
1:1 (row 1): two bars on both ends. Each user has exactly one profile. Usually built by giving user_profile the same primary key as user, which is also its foreign key.
1:N (row 2): bars on the department end, circle plus crow's foot on the employee end. Put the foreign key on the "many" side, never the "one" side.
M:N (row 3): relational tables cannot hold a many-to-many directly, so a junction table enrollment (highlighted) sits in the middle. Each original entity has a 1:N line into it.
Optional 1:1 (row 4): circles on both ends. A parking space can be unassigned and an employee can have no space. A nullable foreign key with a UNIQUE constraint enforces it.
For every line, read entity, outer symbol, inner symbol, other entity: "each department has zero to many employees".
2. How to Read It
There are only four endings. The inner symbol (nearest the entity) is the maximum: bar for one, crow's foot for many. The outer symbol is the minimum: circle for zero (optional), bar for one (mandatory). Mermaid writes them as ||, o|, |{ and o{ (mirrored as }| and }o on the left side of a line).
3. Variant: Optional vs Mandatory
Optionality is not decoration: it decides whether a foreign key column can be NULL. Changing a single bar to a circle on the department end turns NOT NULL into NULL. Reviewing these minimums with the business catches many data-quality bugs before the first row is loaded.
4. Pros, Cons, and When to Use
Pros
Four symbols cover nearly every relationship rule in OLTP schemas.
Minimum and maximum are both visible, unlike plain 1/N labels.
Translates directly into FK placement, NULL-ability and UNIQUE constraints.
Supported by Mermaid, dbdiagram.io, ERwin, draw.io and most SQL IDEs.
Cons
Easy to read from the wrong end and invert the rule.
Cannot express exact counts (at most 3 addresses) without a note.
Subtle symbols are hard to see when diagrams are zoomed out.
Tools differ slightly in how they draw the bar and circle.
When to use
Agreeing relationship rules with domain experts.
Checking FK placement and NULL-ability in schema reviews.
When not to use
Exact numeric limits or time-dependent rules; write constraints or notes instead.
Non-relational document models where nesting replaces joins.
5. As Diagrams-as-Code
MermaiderDiagram for the four patterns:
erDiagram
user ||--|| user_profile : has
department ||--o{ employee : employs
student ||--o{ enrollment : enrols
course ||--o{ enrollment : has
employee |o--o| parking_space : uses