Multiplicity
Multiplicity defines how many instances of one entity can be associated with instances of another in a relationship. It is specified as a range lower..upper on each end of an association in UML class diagrams and ERDs.
Notation
| Notation | Meaning | Example |
|---|---|---|
1 | Exactly one | An order has exactly 1 customer |
0..1 | Zero or one (optional) | An employee has 0 or 1 parking spots |
* or 0..* | Zero or more | A customer has 0 or more orders |
1..* | One or more | An order has at least 1 line item |
n..m | Between n and m | A team has 2..5 members |
Reading Multiplicities
From one class, look at the opposite end: “One instance of Class A is associated with [multiplicity at B’s end] instances of Class B.”
Relationship Types from Multiplicity
| Multiplicity | Relationship Type | Implementation |
|---|---|---|
1 — 1 | One-to-One | Foreign Key with UNIQUE on either table |
1 — * | One-to-Many | Foreign Key on the “many” side |
* — * | Many-to-Many | Junction Table with two FKs |