/en-tutor-prep-ib-cs-databases-relational-erd-schemas/
/en-tutor-prep-ib-cs-databases-relational-erd-schemas/
General Inquiry: info@TutorZone.com.hk
Office Hours: Monday to Saturday - 9:00 AM to 6:00 PM
WhatsApp Monday to Sunday - 24 hours
Hotline: +852 6828 1809
Instant Support: +852 9061 3106

IB Computer Science Relational Databases, ERDs and the Three Schema Levels: Tutor Prep Guide (75 per cent saved, cardinality, keys)

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.

Objectives — Students can: (1) name the five relational features (tables, primary keys, foreign keys, composite keys, relationships), six benefits (less duplication, less redundancy, consistency, integrity, concurrency control, security) and six limitations (big data scaling, design complexity, hierarchical data, rigid schema, object-relational impedance, unstructured data); (2) cost a decomposition on a school database of 1,200 students, 40 courses and 4,800 enrolments: each enrolment repeats name, email and phone at 67 bytes, which is 321,600 bytes before the split and 80,400 after, saving 241,200 bytes or 75.0 per cent, with cells falling from 57,600 to 20,560 (35.69 per cent); (3) explain the update anomaly: one student with 6 enrolments needs 6 rows changed, and if each change is right 99 per cent of the time, all six are right only 94.15 per cent of the time, leaving a 5.85 per cent chance of a stale value; (4) draw an ERD with cardinality and modality: 5 entities and 4 relationships, one student to zero or more enrolments (180 students have none, so 85.0 per cent do), one course to one or more (22 at least, 260 at most, 120 on average); (5) separate the three schema levels and compare a 18 character composite key at 86,400 bytes against a 4 byte surrogate key at 19,200 bytes, which is 4.5 times smaller; (6) explain three data type failures and turn a 4,800 row scan into 13 index probes, 369.2 times faster.

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

Start with a contrast. One wide table copies the student name, email and phone onto every enrolment, so 4,800 enrolments hold 4,800 copies. Split into a student table and an enrolment table, and those three fields are written 1,200 times only.
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

Clear up the commonest confusion first. Cardinality is how many there can be at most; modality is how many there must be at least. Each end of a relationship therefore carries two numbers, and only both together describe the rule.
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

The conceptual schema says what things exist and how they relate, in business words: student, course, enrolment, 5 entities with no data types. The logical schema says how many tables exist, which columns each holds, and which key is primary or foreign, usually six tables at 3NF (three main tables and three lookup tables). The physical schema says which data types, which indexes, and which storage, and belongs to the administrator.
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
Sanity check (teach this): Three checks. First, a saving must be below one hundred per cent: 241,200 over 321,600 is 75.0 per cent, so an answer of 400 per cent has the fraction upside down. Second, cells must equal rows times columns: 4,800 times 12 is 57,600, and the three tables add to 20,560, so both sides must be added table by table. Third, cardinality is never smaller than modality, so writing 0..1 at the course end ignores the 22 enrolments that exist. The commonest misjudgement is that more tables always mean a better design: split too far and every query must join four or five tables, so the join cost outgrows the bytes saved and real systems denormalise a little after 3NF.

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)

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.

Join as a tutor or coach — academic, music, sports, arts, STEM. Free to register. See how it works →