Database systems · Chapter 3 · Cardinality · Worked examples
The Chapter 3 review covers how to read a Chen (min, max) pair once it is already on the page. The harder skill, and the one that actually trips people up when modeling a real database, is going the other direction: starting from a plain sentence and deciding what pair belongs on the diagram. This page is six more business rules, worked all the way from sentence to diagram, plus the mistakes that show up most often along the way.
Every business rule turns into cardinality the same way. Ask two questions about each entity in the relationship, once for each side, and the (min, max) pairs fall out.
| Question | What it fixes |
|---|---|
| For one instance of B, could there be zero matching instances of A? | The minimum: yes means 0 (optional), no means 1 (mandatory) |
| For one instance of B, could there be more than one matching instance of A? | The maximum: no means 1, yes means N, M, or another "many" letter |
Then swap the entities and ask the same two questions again, this time for B. A relationship between two entities always needs the questions asked twice, once from each direction, because the two answers are almost never the same.
Where the sentence hides the answer. Words like must, every, and has to signal a minimum of 1. Words like may, can, and optionally signal a minimum of 0. Words like one and exactly one signal a maximum of 1. Words like many, several, and any number of signal an unspecified maximum. Underlining these words in the business rule before drawing anything is worth the extra thirty seconds.
Example 1
Both sides optional, both sides many: the simplest shape a many to many relationship can take.
Business rule. "A patient may visit many doctors over time. A doctor may see many patients."
Neither sentence uses must, so both minimums are 0. Both sentences use many, so both maximums are unspecified.
Example 2
A 1:1 relationship that is mandatory on one side only, the pairing that surprises people who assume every 1:1 means both sides are required.
Business rule. "A person may or may not have a passport. Every passport belongs to exactly one person."
The first sentence has no must, so PASSPORT's minimum, from PERSON's side, is 0. The second sentence says every, so PERSON's minimum, from PASSPORT's side, is 1. Both sentences cap the count at one, so both maximums are 1.
The trap. It is tempting to see "1:1" and assume (1,1) belongs on both ends. Always re-run the two questions on each side individually; do not infer one side's minimum from the other's.
Example 3
The fully mandatory 1:1, placed right after Example 2 on purpose so the two sit side by side.
Business rule. "Every country must have exactly one capital city. Every capital city belongs to exactly one country."
Both sentences use every and must, so both minimums are 1. Both cap the count at one, so both maximums are 1.
Example 4
A many to many relationship where the two minimums do not match, a very common real pattern that still catches people off guard.
Business rule. "An order must include at least one product. A product may appear on many orders, or none yet."
An order without a product is not really an order, so PRODUCT's minimum, from ORDER's side, is 1. A brand new product that has not sold yet has zero orders, so ORDER's minimum, from PRODUCT's side, is 0.
Example 5
A 1:M relationship, mandatory on the "one" side, optional on the "many" side, the shape most foreign key relationships end up taking.
Business rule. "Every student must be assigned exactly one advisor. An advisor may be assigned zero, one, or many students."
Every student needs an advisor, so ADVISOR's minimum, from STUDENT's side, is 1, capped at one. A new advisor might not have any students yet, so STUDENT's minimum, from ADVISOR's side, is 0, uncapped.
Example 6
Another many to many relationship, one side mandatory, the other optional, this time needing its own bridge entity to actually build.
Business rule. "A book must have at least one author, and may have several. An author may write zero, one, or many books."
A book with no listed author is not publishable, so AUTHOR's minimum, from BOOK's side, is 1, uncapped since a book can have several authors. A first time author has written zero books until the record exists, so BOOK's minimum, from AUTHOR's side, is 0.
Five ways a correct business rule turns into an incorrect diagram, roughly in order of how often each one shows up.
| Mistake | Fix |
|---|---|
| Writing the pair backward, like (M,1) instead of (1,M) | Minimum always comes first. If the sentence gives you a "many" and a "required," the required number goes second, not first: (1, M), never (M, 1). |
| Assuming every 1:1 relationship is mandatory on both sides | 1:1 only fixes both maximums at 1. Ask the minimum question separately for each side; see PERSON/PASSPORT above against COUNTRY/CAPITAL_CITY. |
| Copying one side's minimum onto the other side | The two minimums come from two different sentences almost every time. ORDER/PRODUCT above has a 1 on one side and a 0 on the other from the same relationship. |
| Placing the pair next to the wrong entity | The pair sits next to the entity it counts, but it counts that entity per one instance of the entity on the far end. See the placement trap covered in the Chen notation section. |
| Treating "usually" or "typically" as if it meant "must" | Only a hard requirement earns a minimum of 1. A rule that describes the common case, not a rule the database has to enforce, gets a minimum of 0 instead. |