We’re moving to a new home! Our website is currently in test mode while we update and transfer our content. Some pages and resources may be temporarily unavailable. We’ll be back with all resources shortly. Thank you for your patience.

IB Computer Science | A3.2.5 Normal Forms

Lesson objective

Explain the differences between 1NF, 2NF and 3NF using atomicity, unique identification and functional dependencies. Identify how poor design causes duplication, missing data and dependency problems.

Learn

A3.2.5 | NORMAL FORMS

01 | WHY NORMALIZE?

A robotics club keeps one spreadsheet for students, projects and mentors. It works until a mentor changes email address. The address appears on ten rows, and someone updates only nine. Which version should the club trust?

Normalization organizes relational tables according to their dependencies. The aim is to reduce unnecessary duplication and the problems it creates, while preserving the facts and relationships we need.

  • Update anomaly: repeated facts must be changed in several places, risking inconsistent versions.
  • Insertion anomaly: a fact cannot be recorded without an unrelated fact—for example, a new project cannot be stored until a student joins it.
  • Deletion anomaly: deleting one fact accidentally removes another—for example, deleting the last enrolment also removes the only record of a project.

“Missing data” can therefore mean a fact cannot be entered or has been accidentally lost. A NULL value is not, by itself, proof that a table violates a normal form. Normalization improves structure; it does not automatically repair incomplete or inaccurate records.

02 | BEFORE WE START: KEYS AND DEPENDENCIES

A field or attribute is a column, such as StudentName. A record is a row. A key lets us identify a particular row without confusing it with another.

Why not use a name? Two students could both be called Alex. A name therefore does not reliably identify a student. The club gives each student a unique StudentID.

Key example only: these extra email values illustrate possible student keys
StudentIDStudentNameSchoolEmail
S01Alexalex01@example.org
S02Rinrin02@example.org
S03Alexalex03@example.org

A candidate key is a possible choice of key: it must be unique and minimal. “Minimal” means no attribute can be removed while keeping uniqueness. If club rules guarantee that both StudentID and SchoolEmail are individually unique, each is a candidate key. StudentName is not.

We choose StudentID as the primary key (PK). SchoolEmail remains another candidate key. The combination (StudentID, SchoolEmail) is unique, but it is not minimal because StudentID alone already identifies the student. The email field above is only a key illustration; our worked normalization example uses StudentID and StudentName.

A composite key needs more than one field. In ENROLMENT, StudentID repeats because a student can join several projects. ProjectID repeats because a project can have several students. Together, (StudentID, ProjectID) identifies one student’s enrolment in one project. We assume at most one enrolment for each pair.

Neither ID is unique here, but each StudentID–ProjectID pair is unique
StudentIDProjectIDRole
S01P10Coder
S01P20Driver
S02P10Builder

A foreign key (FK) refers to a key in another table. ENROLMENT.StudentID points to STUDENT.StudentID. It lets us connect the enrolment to the correct student without copying the student’s details.

What does “depends on” mean? Ask: “If I know this value, does it determine exactly one value of that field?” Knowing StudentID S01 determines the name Alex. StudentName therefore depends on StudentID. We write StudentID → StudentName and read it as “StudentID determines StudentName”.

This is a functional dependency. It describes a rule about values—not a calculation, a processing order, or which column comes first. Knowing Alex does not determine one StudentID because two students may share that name.

Dependencies used throughout the worked example
If we know…We can determine…Why?
StudentIDStudentNameAn identifier belongs to one student
ProjectIDProjectName and MentorIDEach project has one name and one assigned mentor
MentorIDMentorEmailEach mentor has one recorded email
StudentID AND ProjectIDRoleA student can have different roles on different projects

These dependencies follow our club’s rules, not just coincidences in the sample rows. If the rules change—for example, one project can have several mentors—the design must change too.

03 | FIRST NORMAL FORM: ONE VALUE PER CELL

1NF requires atomic values and no repeating groups. Atomicity here means that a cell contains one value from the attribute’s domain, not a list of values. It is different from transaction atomicity in ACID.

Before 1NF: one cell holds several enrolments
StudentIDStudentNameProjects and roles
S01AlexP10: Robot hand / Coder; P20: Delivery robot / Driver
S02RinP10: Robot hand / Builder

For S01, the final cell contains two project–role pairs. To search or update one enrolment, we would have to unpack the list. Move each pair into its own row and give each field one value. Add the related project and mentor fields to produce the 1NF table below.

A cell containing ProjectIDs “P10, P20” is not atomic when the database needs to treat each enrolment separately. Columns Project1, Project2 and Project3 are a repeating group. Instead, store one enrolment per row and identify it with a key.

Atomic does not mean “one word” or “one character”. A project name such as “Robot hand” can be one value. Whether an address needs separate fields depends on what the application must do with it.

Enrolment table in 1NF; composite primary key: (StudentID, ProjectID)
StudentIDStudentNameProjectIDProjectNameMentorIDMentorEmailRole
S01AlexP10Robot handM01lee@example.orgCoder
S01AlexP20Delivery robotM02sam@example.orgDriver
S02RinP10Robot handM01lee@example.orgBuilder

Every cell is a single value, and each enrolment is uniquely identified. However, student and project details still repeat. 1NF is the starting point, not a promise that redundancy has disappeared.

04 | SECOND NORMAL FORM: DEPEND ON THE WHOLE KEY

A None-prine attribute does not belong to any candidate key.

2NF means the table is in 1NF and has no partial-key dependencies of non-key attributes. More precisely, every non-prime attribute must depend on the whole of each candidate key, not just a proper subset. A non-prime attribute is one that belongs to no candidate key.

In our table, the key is (StudentID, ProjectID), but StudentName depends on StudentID alone. ProjectName and MentorID depend on ProjectID alone. These are partial dependencies. Role needs both identifiers, so it is a full dependency on the composite key.

Separate the student facts, project facts and enrolment facts:

STUDENT(StudentID PK, StudentName)

PROJECT(ProjectID PK, ProjectName, MentorID, MentorEmail)

ENROLMENT(StudentID PK/FK, ProjectID PK/FK, Role)

Follow what moved: take StudentID and StudentName into STUDENT because a name depends only on the student. Take ProjectID, ProjectName, MentorID and MentorEmail into PROJECT because these details depend on the project. Keep both IDs and Role in ENROLMENT because a role belongs to a particular student–project pair.

2NF — STUDENT: each student’s name is stored once
StudentID (PK)StudentName
S01Alex
S02Rin
2NF — PROJECT: each project’s details are stored once
ProjectID (PK)ProjectNameMentorIDMentorEmail
P10Robot handM01lee@example.org
P20Delivery robotM02sam@example.org
2NF — ENROLMENT: primary key = (StudentID, ProjectID)
StudentID (PK part / FK)ProjectID (PK part / FK)Role
S01P10Coder
S01P20Driver
S02P10Builder
Why keep Role here? S01 is the coder on P10 but the driver on P20. StudentID alone is not enough to tell us the role. We need the whole composite key.

Why is PROJECT not yet 3NF? The sample happens to show a different mentor for each project. But club rules allow one mentor to supervise several projects. Their email would then repeat in PROJECT. Normal forms depend on the rules, not whether today’s sample contains repetition.

The two ENROLMENT fields jointly form its primary key, and each is also a foreign key linking to its parent table. Now a student’s name is stored once, and an unassigned project can be recorded without inventing an enrolment.

Key insight: if all candidate keys are single attributes, a 1NF table has no partial-key dependency and is already in 2NF. This does not guarantee 3NF.

05 | THIRD NORMAL FORM: REMOVE TRANSITIVE DEPENDENCIES

3NF builds on 2NF. In the straightforward designs used here, non-key attributes must not depend on the key through another non-key attribute. This is a transitive dependency.

The PROJECT table still stores MentorEmail. ProjectID determines MentorID, and MentorID determines MentorEmail. Thus the email depends indirectly on ProjectID:

ProjectID → MentorID → MentorEmail

If one mentor supports several projects, their email repeats. Move the mentor’s details into a MENTOR table, keeping MentorID in PROJECT as a foreign key:

STUDENT(StudentID PK, StudentName)

MENTOR(MentorID PK, MentorEmail)

PROJECT(ProjectID PK, ProjectName, MentorID FK)

ENROLMENT(StudentID PK/FK, ProjectID PK/FK, Role)

Follow the final move: Student and Enrolment stay as they were. Remove MentorEmail from PROJECT and store it with MentorID in MENTOR. Keep MentorID in PROJECT so we still know which mentor supervises each project.

3NF — STUDENT: each student’s name is stored once
StudentID (PK)StudentName
S01Alex
S02Rin
3NF — PROJECT: mentor email has moved out; mentor ID stays
ProjectID (PK)ProjectNameMentorID (FK)
P10Robot handM01
P20Delivery robotM02
3NF — MENTOR: one email per mentor
MentorID (PK)MentorEmail
M01lee@example.org
M02sam@example.org
3NF — ENROLMENT: primary key = (StudentID, ProjectID)
StudentID (PK part / FK)ProjectID (PK part / FK)Role
S01P10Coder
S01P20Driver
S02P10Builder

Can we still find everything? Start with ENROLMENT (S01, P10, Coder). S01 links to Alex in STUDENT. P10 links to Robot hand and mentor M01 in PROJECT. M01 links to lee@example.org in MENTOR. The facts are separated, but the identifiers let us put the information together again.

If M01 later supervises another project, that project stores M01 as its foreign key. We do not copy the email. A changed email needs one update in MENTOR.

A mentor’s email now has one home. Tables remain connected through keys, so joins can reconstruct the needed student–project–mentor information. Splitting tables should preserve information, not break relationships.

Optional: the formal definition of 3NF

for every non-trivial functional dependency X → A in 3NF, X is a superkey or A is a prime attribute (part of a candidate key). The “no non-key transitive dependencies” rule is the practical test for our simple examples.

06 | COMPARE THE NORMAL FORMS

Each normal form adds requirements to the previous one
FormMust already satisfyMain testTypical repair
1NFRelational table structureAtomic values; no repeating groups; unique rowsOne fact or relationship instance per row
2NF1NFNo non-key partial dependency on any candidate keySeparate facts about each part of a composite key
3NF2NFNo non-key transitive dependency in these examplesMove the indirectly dependent fact to its own table

A useful question sequence is: “One value? Whole key? No indirect non-key dependency?” Always identify the keys and dependencies before deciding the highest normal form. A small sample may hide repetition that will appear later.

Normalization does not remove every repeated value: foreign keys legitimately appear in several rows. It removes unnecessary repetition of facts and the dependencies that cause anomalies.

07 | MULTI-VALUED DATA AND OTHER DEPENDENCY CONCERNS

A multi-valued cell contains a list, such as Skills = “Python, CAD”. When those skills need separate handling, a related STUDENT_SKILL table with one skill per row supports 1NF.

A multi-valued dependency is a different issue. Suppose a student has several skills and several hobbies, and the two sets are independent. A table (StudentID, Skill, Hobby) may require every skill–hobby combination, creating redundant rows even though each cell is atomic.

Independent skills and hobbies create repeated combinations
StudentIDSkillHobby
S01PythonCycling
S01PythonChess
S01CADCycling
S01CADChess

Separate STUDENT_SKILL(StudentID, Skill) and STUDENT_HOBBY(StudentID, Hobby) when the sets are genuinely independent. This is associated with 4NF, beyond the three normal forms being compared here. Do not claim that 1NF–3NF automatically remove every multi-valued dependency.

Likewise, adding an artificial ID does not remove the original dependencies. You must examine all candidate keys and the data’s meaning, not simply rename the primary key.

DEPENDENCY DETECTIVE

Match each problem or dependency to the correct description.

08 | EXPLAIN, DON’T JUST LABEL

To explain a normal form, name its requirements, show the dependency or structural problem, and describe the change that resolves it. “Split the table” is not enough: identify which attributes move, what their key is, and how the tables remain linked.

For example: “StudentName depends only on StudentID, part of the composite key, so the table violates 2NF. Move StudentID and StudentName into STUDENT and retain StudentID in ENROLMENT as a foreign key.”

Further reading: Microsoft’s database design guide and IBM’s normalization overview.

WATCH | USEFUL VIDEOS

Use these videos to revisit the explanations and compare them with the worked tables above.

Links open in a new tab.

Terminology

Terminology

Normalization

Organizing relations according to dependencies to reduce unnecessary redundancy and anomalies.

Atomicity in 1NF

One value per cell from the chosen domain; no list or repeating group.

Unique identification

A candidate key uniquely identifies each row; one candidate key is selected as the primary key.

Composite key

A key made from more than one attribute.

Functional dependency

X → Y: each value of X determines exactly one value of Y under the data rules.

Partial-key dependency

A non-prime attribute depends on a proper subset of a candidate key.

Transitive dependency

An attribute depends indirectly on a key through another attribute; a non-key example is ProjectID → MentorID → MentorEmail.

1NF

Atomic values and no repeating groups, with uniquely identifiable rows.

2NF

1NF plus no partial dependencies of non-prime attributes on candidate keys.

3NF

For each non-trivial X → A, X is a superkey or A is prime; in simple examples remove non-key transitive dependencies.

Anomaly

An update, insertion or deletion problem caused by the organization of data.

Multi-valued dependency

One determinant is associated with an independent set of values; different from simply storing a list in a cell.

Questions

Questions

TICK-BOX KNOWLEDGE CHECK

Select all correct choices. One point for each exact set.

1. Which changes are needed for 1NF?
2. Which dependencies violate 2NF in our 1NF enrolment table?
3. Which statements about 3NF are correct for our example?
4. What is transaction atomicity compared with 1NF atomicity?
5. Which example is a deletion anomaly?
6. Which statements are correct?
7. Which describes a multi-valued dependency?
8. Which repeated values can be appropriate in normalized tables?

WRITTEN QUESTIONS

Answer in your book before revealing the samples. These are original practice questions and suggested answers, not official IB questions or mark schemes.

1. Explain the difference between 1NF, 2NF and 3NF.

2. Explain why StudentName violates 2NF in the original enrolment table.

3. Show the tables needed to bring the club example into 3NF. State keys.

4. Explain how the 3NF design prevents the mentor-email update anomaly.

5. Explain insertion and deletion anomalies using the club example.

6. Distinguish a list in a cell from an independent multi-valued dependency.

7. A developer adds RowID to the original table. Has the dependency problem been solved? Explain.

8. Explain why normalization does not mean no value may ever repeat.

Flashcards

Flashcards

Flip any card to reveal the answer. Tick the ones you need to revisit.

0 cards selected for revision.

    Selections are kept while this page is open.

    Workbook

    Workbook

    COMING SOON

    The workbook for A3.2.5 Normal Forms is coming soon. For now, use the written questions and sketch the tables and dependency arrows in your book.