DBMS 📂 Entity-Relationship (ER) Model · 2 of 5 31 min read

Cardinality in DBMS

A complete, example-driven guide to cardinality in the Entity-Relationship model. It explains connectivity (1:1, 1:M, M:1, M:M), the l..h minimum–maximum notation, the link between cardinality and participation, and how each cardinality decides foreign-key placement and junction tables — illustrated with animated diagrams and the Customer–Loan and Supplier–Part examples.

Section 01

The Story That Explains Cardinality

The Wedding Seating Question
A wedding planner asks two questions about every guest. First: "Does this guest have a partner, and can a partner have more than one guest?" — that is the type of pairing. Second: "Exactly how many seats does this family need — at least one, at most six?" — that is the count.

A database designer asks the very same two questions about every relationship. How are the two entities paired (one–to–one, one–to–many…) and how many occurrences are allowed at each end (minimum and maximum)? Answering them is the whole job of cardinality.

When you draw an Entity-Relationship diagram, the boxes and diamonds only tell you that two entities are related. Cardinality tells you the crucial extra detail: how many entities on one side may be linked to entities on the other. Get it wrong and your tables will store impossible data or refuse to store valid data.

💡
The Core Definition

The cardinality of a relationship is the actual number of related occurrences for each of the two entities. An ER diagram provides a way to mark this count directly on the edges connecting entities to a relationship.


Section 02

Two Ideas Hiding in One Word

Textbooks often blur two related but distinct ideas. Keeping them separate makes everything click into place.

🔗
Connectivity
The "shape" of the mapping
Describes the mapping of associated entity instances in the relationship. Its values are simply "one" or "many", giving the four familiar patterns: 1:1, 1:M, M:1, M:M.
🔢
Cardinality (count)
The exact numbers
Describes the actual number of related occurrences for each entity. It is written as a range l..h on an edge, where l is the minimum and h is the maximum cardinality.
✔️
Participation
Optional or mandatory
Falls straight out of the minimum cardinality. A minimum of 1 means total participation; a minimum of 0 means partial participation. We return to this in Section 08.
🔑
One-Line Memory Hook

Connectivity answers "one or many?"Cardinality answers "how many, at least and at most?"Participation answers "is taking part compulsory?"


Section 03

Connectivity — The Four Mapping Types

Because each side can be "one" or "many", there are exactly four ways two entities can be paired. Watch them build up one by one.

📊 The Four Connectivity Patterns
ONE-to-ONE (1:1) PERSON HAS PASSPORT 1 1 ONE-to-MANY (1:M) CUSTOMER HAS LOAN 1 M MANY-to-ONE (M:1) EMPLOYEE WORKS DEPARTMENT M 1 MANY-to-MANY (M:M) SUPPLIER SUPPLIES PART M M

M:1 is simply 1:M viewed from the opposite direction — the same relationship, read the other way.

ConnectivityReads AsEveryday Example
1 : 1One A ↔ one BPerson ↔ Passport
1 : MOne A → many BCustomer → Loans
M : 1Many A → one BEmployees → Department
M : MMany A ↔ many BSuppliers ↔ Parts

Section 04

One-to-Many in Action — Customer & Loan

Connectivity is easiest to feel with real rows. In the bank below, one customer can take many loans, but each loan belongs to exactly one customer — a textbook 1:M relationship. The animated lines show how individual instances map.

🏦 CUST–LOAN — one Customer maps to many Loans
C_No Name C1 RAJ C2 RAM C3 SHAM CUSTOMER L_No Amount L1 10000 L2 20000 L3 10000 LOAN C1 owns L1 & L2 • C2 owns L3 • each loan has one owner

Customer C1 (RAJ) maps to two loans — that is the "many" side. No loan ever points to two customers — that is the "one" side.

How to Read Connectivity From Data

Pick one row on the left and count its arrows: C1 has two → the right side is "many". Pick one row on the right and count its arrows: L1 has one → the left side is "one". Two counts, and the pattern (1:M) reveals itself.


Section 05

Many-to-Many in Action — Supplier & Part

The trickiest pattern is M:M. A supplier can supply many parts, and a part can be supplied by many suppliers. Notice the crossing lines — that tangle is the visual signature of a many-to-many relationship.

📦 SUPPLIER–PART — many maps to many, with QTY on the link
QTY descriptive attribute of the relationship SNo Name S1 RISHAN S2 RAHAT S3 RUHI PNo PName P1 PEN P2 PENCIL P3 ERASER

S1 supplies P1 and P3; P1 is supplied by S1 and S2. Both sides are "many", so this is M:M — and the quantity supplied (QTY) belongs to the link, not to either entity.

⚠️
Why M:M Always Needs Its Own Table

There is nowhere to store QTY in either the Supplier or the Part table — it depends on the pair. That is why every M:M relationship is implemented as a separate junction table. We show exactly how in Section 09.


Section 06

Cardinality Notation — the l..h Range

Connectivity gives the rough shape; the l..h notation gives the precise numbers. An edge between an entity set and a relationship set can carry an associated minimum and maximum cardinality, written l..h, where l is the lowest and h the highest number of occurrences allowed.

📐 Reading l..h on the edges
CUSTOMER HAS LOAN 0..* 1..1 a customer may hold 0 to many loans a loan belongs to exactly 1 customer

Read each edge as "this entity participates a minimum of l and a maximum of h times". Here: a loan needs exactly one owner (1..1), a customer may have any number of loans (0..*).

l..h LabelMinimumMaximumMeaning
1..111Exactly one — mandatory and single
0..101At most one — optional, single
1..*1manyAt least one — mandatory, many
0..*0manyAny number — optional, many
The Star Means "Many"

The symbol * (or N) in the high position means "no fixed upper limit". So 1..* reads as "one or more", and 0..* reads as "zero or more".


Section 07

Connectivity vs Cardinality — Side by Side

Both describe a relationship, but at different levels of precision. This comparison settles the confusion for good.

🔗 Connectivity
Describes the mapping of entity instances
Values are only "one" or "many"
Four types: 1:1, 1:M, M:1, M:M
Answers: "what shape is the link?"
🔢 Cardinality
The actual number of related occurrences
Expressed as a precise range
Written as l..h (min..max) on an edge
Answers: "exactly how many, at least and at most?"
💡
How They Fit Together

Connectivity is the headline; cardinality is the fine print. A "one-to-many" headline (connectivity) becomes precise when you add the ranges: the "one" side is 1..1 and the "many" side is 0..* (cardinality).


Section 08

Cardinality & Participation

The minimum half of the l..h range carries a second meaning: it decides whether an entity's participation in the relationship is compulsory.

🧮 Minimum Cardinality → Participation Rule
min = 1
Total participation. Every entity in the set must take part — e.g. every loan must have a customer. Shown as a double line.
min = 0
Partial participation. Some entities may stay out — e.g. not every customer has a loan. Shown as a single line.
1..*
The label 1..* on an edge is equivalent to a double line — both say "at least one, so participation is total".
➡️ Single line (min 0) vs Double line (min 1)
Partial — single line (0..*) CUSTOMER HAS Total — double line (1..*) LOAN HAS A customer need not have a loan A loan must have a customer

Cardinality (the count) and participation (optional vs mandatory) are decided separately — but both are read from the same l..h label.


Section 09

How Cardinality Shapes Your Tables

Cardinality is not just decoration — it dictates exactly how a relationship becomes real tables. Two rules cover almost every case.

📋 Cardinality → Table Design
1
1:M → put a foreign key on the "many" side. No extra table is needed. The Loan table gains a Cust_ID column, so the same customer can appear against several loans.
2
M:M → create a new junction table. It holds both primary keys plus any attribute that belongs to the link (such as QTY). This is the only way to store a many-to-many fact.
3
1:1 → merge or add a foreign key on either side. A single foreign key (often with a uniqueness constraint) is enough; sometimes both entities collapse into one table.

1:M Mapping — the foreign key lands in LOAN

Because customer C1 has two loans, C1 simply appears twice in the foreign-key column — perfectly legal on the "many" side.

-- 1:M : foreign key Cust_ID added to the many side
CUSTOMER ( Cust_ID PK, Name, City )
LOAN     ( Loan_No PK, Amount, Cust_ID FK )

-- LOAN rows: C1 may repeat, no loan repeats
--  Loan_No | Amount | Cust_ID
--   L1     | 10000  |  C1
--   L2     | 20000  |  C1   <- same customer, second loan
--   L3     | 10000  |  C2

M:M Mapping — a junction table for SUPPLIER–PART

-- M:M : a new table holds both keys plus the link attribute
SUPPLIER ( SNo PK, Name )
PART     ( PNo PK, PName )
SUPPLIES ( SNo FK, PNo FK, QTY )
         -- Primary key = (SNo, PNo)

Section 10

Common Mistakes to Avoid

⚠️
Mistake 1 — Reading the cardinality backwards

In a 1:M, the "1" sits beside the entity on the one side, but it describes how the other side links to it. Always test with data: pick one row and count its partners on the opposite table.

⚠️
Mistake 2 — Trying to store M:M in two tables

You cannot. A foreign key column can hold only one value per row, so it can never represent "many on both sides". The moment both sides are "many", you need a junction table — no exceptions.

⚠️
Mistake 3 — Confusing the count with participation

The maximum (1 or many) is the connectivity; the minimum (0 or 1) is the participation. A relationship can be 1:M and total at the same time — the two facts are independent.


Section 11

Quick Reference

Connectivity"One" Side l..h"Many" Side l..hMaps ToExample
1 : 10..1 / 1..10..1 / 1..1FK on either sidePerson – Passport
1 : M1..10..*FK on many sideCustomer – Loan
M : 10..*1..1FK on many sideEmployee – Dept
M : M0..*0..*Junction tableSupplier – Part
Symbol / LabelMeans
1 beside an edgeThe "one" side of connectivity
M or *The "many" side of connectivity
l..hMinimum (l) and maximum (h) cardinality
Single linePartial participation (min = 0)
Double lineTotal participation (min = 1, i.e. 1..*)

Section 12

Golden Rules of Cardinality

🏆 Cardinality — Non-Negotiable Rules
1
Always determine cardinality from the business rules, not from convenience. "Can a customer have two loans?" is a question for the bank, not the diagram.
2
Test connectivity with sample data. Pick one instance on each side and count its partners. Two counts give you the full pattern (1:1, 1:M, M:1, or M:M).
3
Read l..h as "minimum then maximum". The first number controls participation; the second number controls connectivity. Never swap them.
4
Every M:M relationship becomes a junction table. If a relationship has its own attribute (like QTY), that alone proves you need the junction table.
5
Place the foreign key on the "many" side of a 1:M. The single side never holds the key, because it would then need many values in one cell.
6
Treat cardinality and participation as separate decisions. First ask "how many?" then ask "is it mandatory?" A relationship can be 1:M and total at once.