IB Computer Science Relational Databases, ERDs and the Three Schema Levels: Tutor Prep Guide (75 per cent saved, cardinality, keys)
- 2026-11-27
Students answer that a database stores a lot of data, then freeze when asked why one table must become three, or what the 1 and the 0..N on an ERD actually mean. This lesson ties the three abstract words to three measurable answers: bytes, update counts and index probes.
01 Prerequisites (3-minute check)
If any of these fails, fix it before the lesson starts.
| Skill | Quick check | Pass mark |
|---|---|---|
| The job of a primary key | Why two rows cannot share the same primary key | It must be unique and never empty |
| Percentages and ratios | Out of 321,600 bytes, what percentage is 241,200 | Difference over the original, times one hundred |
| Reading a simple diagram | What the split end of a line on an ERD means | One to many, or one to one |
02 Lesson flow (60 minutes)
| Time | Stage | Tutor does | Student does |
|---|---|---|---|
| 0-8 min | Opening check | Ask what happens when one phone number is stored four times and changed three times | Write an answer, compare at the end |
| 8-22 min | Relational features and decomposition | 4,800 enrolments repeat 67 bytes: cost the saving | Compute bytes and cells |
| 22-38 min | ERD cardinality and modality | 5 entities, at least 22 and at most 260 | Draw and label both ends |
| 38-50 min | Schema levels and keys | A 18 character composite key against a 4 byte surrogate | Choose a key and justify it |
| 50-57 min | Data types | A leading zero, date ordering, and 0.1 plus 0.2 on money | Pick a type per column |
| 57-60 min | Exit check | Collect and mark three items | Work independently |
03 Teaching script (read it out)
Scene 1: The relational model: not storing a lot, but writing each fact once
Do the arithmetic: each enrolment repeats 67 bytes, so the flat table is 4,800 times 67, which is 321,600 bytes, and the split version is 1,200 times 67, which is 80,400 bytes. The saving is 241,200 bytes, or 75.0 per cent. Count cells as well: 4,800 rows times 12 columns is 57,600 cells, while three tables (five student columns, four course columns, three enrolment columns) hold 20,560 cells, which is 35.69 per cent, so 64.31 per cent of the original was duplication.
The update bill is worse. One student has 6 enrolments, so a new phone number means 6 rows changed. If each change is correct 99 per cent of the time, all six are correct only 94.15 per cent of the time, so there is a 5.85 per cent chance that one row keeps the old number. That is the update anomaly, and it is the answer to the favourite exam question about why we normalise.
Tie each benefit to the example: less duplication and less redundancy are the same fact seen twice (fewer writes, fewer bytes); consistency means one change propagates everywhere; integrity means a foreign key stops an enrolment pointing at a course that does not exist; concurrency control protects two clerks editing the same row; security means column level rights. The limitations are just as concrete: a rigid schema means altering a column alters the table, unstructured data such as a student essay fights the model, and billions of rows force sharding.
Student task: identify the column that repeats most often and how many times, then say which table it lives in after the split.
Scene 2: ERD: cardinality is the maximum, modality is the minimum
Draw 5 entities (student, course, enrolment, teacher, room) and 4 relationships. Student to enrolment is one to many: at most many, at least zero, because 180 of the 1,200 students have no enrolment this term, leaving 1,020 (85.0 per cent) who do, so the modality is zero. Course to enrolment is also one to many, but the modality is one: the smallest of the 40 courses still has 22 enrolments, and none has zero, so a course must have at least one.
A many to many relationship such as student to course is resolved by an associative entity, the enrolment table, which turns one many to many into two one to many relationships. That is the step students skip: drawing one line with M and N at the ends is not an answer; the middle table has to appear, and its primary key is the two foreign keys together.
Student task: for three cases (one book with several authors, one room with several lessons, one teacher with several subjects), draw the ERD and state where an associative entity is needed.
Scene 3: Three schema levels and keys: the same database drawn three ways
Cost the key choice: an enrolment composite key of a student code of 8 characters, a course code of 6 and a term of 4 is 18 characters per row, so 4,800 rows take 86,400 bytes. A 4 byte surrogate key takes 19,200 bytes, which is 4.5 times smaller. The surrogate has a cost: a unique index on the three columns is still needed, otherwise the same student can enrol twice in the same course in the same term.
Cost the index: to find one email among 4,800 rows, a full scan reads up to 4,800 rows, while a B tree of depth 13 needs at most 13 probes, which is 369.2 times fewer. The price is that every insert must update the index, so not every column earns one.
Three data type failures. A phone number stored as an integer drops the leading zero, so a Hong Kong number of 8 digits comes back with 7. A date stored as text sorts wrongly, because 2026-10-01 sorts before 2026-9-1 letter by letter, so use a DATE type or zero padded ISO text. Money stored as floating point gives 0.30000000000000004 for 0.1 plus 0.2, and ten thousand additions of 0.1 drift by cents, so money uses DECIMAL or an integer count of the smallest unit.
Student task: for five columns (phone, date, money, identity number, score), name the type and the reason, and say which one must never be used for arithmetic.
04 Question types and worked steps
| Type | Example | Steps | Answer |
|---|---|---|---|
| Costing a decomposition | 4,800 enrolments repeat name, email and phone at 67 bytes over 12 columns | Total the flat table, total the three 3NF tables, then divide the difference by the original | 241,200 bytes, 75.0 per cent; cells at 35.69 per cent |
| Drawing an ERD with cardinality and modality | 5 entities, 1,200 students, 40 courses, at least 22 enrolments | Fix the entities, then write the maximum and the minimum at each end, and open an associative entity for many to many | 4 relationships; student 0..N, course 1..N |
| Choosing between composite and surrogate keys | A 18 character composite against a 4 byte surrogate over 4,800 rows | Total both, then explain that the surrogate still needs a unique index on the combination | 86,400 against 19,200 bytes, 4.5 times smaller |
| Diagnosing a wrong data type | Phone as integer, date as text, money as float | Name what is lost in each case: leading zero, sort order, exactness | Answering only that it looks different is not enough |
05 Independent practice (3 questions)
| Question | Answer | What to watch |
|---|---|---|
| 4,800 enrolments each repeat 67 bytes of student data, and 1,200 students remain after the split. What percentage is saved? | 75.0 per cent (321,600 falls to 80,400, a saving of 241,200) | Whether the original was the denominator |
| One student has 6 enrolments and each row is changed correctly 99 per cent of the time. What is the chance all six are right? | 94.15 per cent, so a 5.85 per cent chance of a stale value | Whether the six were multiplied rather than added |
| A 18 character composite key over 4,800 rows against a 4 byte surrogate: how many times larger is the total? | 86,400 against 19,200 bytes, 4.5 times larger | Whether both were multiplied by the row count |
06 Common mistakes and what to say
| Mistake | Student writes | Say this |
|---|---|---|
| Treating normalisation as more tables is better | Answering that fifth normal form is always best | “The split removes duplication and update anomalies, but every extra table adds a join. A database of 1,200 students stops at 3NF; going further only slows the queries.” |
| Confusing cardinality with modality | Writing that one student has many enrolments, so both ends are N | “Cardinality is the maximum and modality the minimum. The student end is 0..N because 180 have none, and the course end is 1..N because the smallest course still has 22.” |
| Storing a phone number as an integer | Answering that a phone number is numeric, so use INTEGER | “A Hong Kong number starts with zero and an integer drops it. Store eight characters with CHAR or VARCHAR, because nobody adds phone numbers.” |
| Thinking an ERD line only means related | Drawing a line with no numbers at either end | “Every line answers three questions: which two entities, how many at most, how many at least. A line without numbers says nothing.” |
07 Homework (paper, section and question numbers)
- IB Computer Science chapter index — All chapters in this subject
- SQL, DDL and DML, and data warehouses — The other chapter: five join steps, WHERE against HAVING, star schema
- Tutor prep guide index — Matching chapters in other subjects
08 Exit check (last 5 minutes)
| Question | Answer | Decision |
|---|---|---|
| Relational features | Tables, primary keys, foreign keys, composite keys, relationships | Answering only that it stores data means replay act one |
| Cardinality and modality | Maximum and minimum, both ends | Missing 0..N and 1..N means replay act two |
| Schema levels | Conceptual entities, logical tables, physical types and indexes | Treating the three as one means replay act three |
09 Tutor FAQ
How far into normal forms should the lesson go?
A3.2 asks for tables and integrity rather than numbered normal forms. 3NF is enough in class: 1NF keeps one value per cell, 2NF removes partial dependency, 3NF removes transitive dependency, and all three can be shown on the enrolment example. BCNF and fourth normal form are extensions.
Which ERD notation should students use?
IB names none. Crow foot suits a Hong Kong classroom because cardinality and modality are exactly the fork and the circle at each end. Chen notation with diamonds and ovals also works. What is marked is the two numbers at each end, not the shapes.
A3.4 is HL only, so what do SL students need?
A3.1 to A3.3 are for both levels and A3.4 is entirely HL. SL students only need to know that the relational model is not the only option, without the detail of four NoSQL families.
Find a tutor — freeTutor Registration →
A TutorZone lesson-prep guide. Written by the TutorZone team; questions and lesson flow are original and are not taken from any school or publisher material.



