← back

Normalisation Task

Our task was to take a table of data and "normalise" it. I found it very useful to apply my learning about database normalisation forms to an actual table of data - it really helped me consolidate my learning. This will help me use database normalisation forms in future projects, which may be much larger and more complicated.

Here is the original table of data.

Student Number Student Name Exam Score Support Date of Birth Course Name Exam Boards Teacher Name
1001 Bob Baker 78 No 25/08/2001 Computer Science
Maths
Physics
BCS
EdExcel
OCR
Mr Jones
Ms Parker
Mr Peters
1002 Sally Davies 55 Yes 02/10/1999 Maths
Biology
Music
AQA
WJEC
AQA
Ms Parker
Mrs Patel
Ms Daniels
1003 Mark Hanmill 90 No 05/06/1995 Computer Science
Maths
Physics
BCS
EdExcel
OCR
Mr Jones
Ms Parker
Mr Peters
1004 Anas Ali 70 No 03/08/1980 Maths
Physics
Biology
AQA
OCR
WJEC
Ms Parker
Mr Peters
Mrs Patel
1005 Cheuk Yin 45 Yes 01/05/2002 Computer Science
Maths
Music
BCS
EdExcel
AQA
Mr Jones
Ms Parker
Ms Daniels

I demonstrated 1NF, 2NF and 3NF by splitting the data into 3 tables.

The first table is for students.

Student NumberStudent NameExam ScoreSupportDate of Birth
1001Bob Baker78No25/08/2001
1002Sally Davies55Yes02/10/1999
1003Mark Hanmill90No05/06/1995
1004Anas Ali70No03/08/1980
1005Cheuk Yin45Yes01/05/2002

The second table is for courses.

Course NumberCourse NameExam BoardTeacher Name
1Computer ScienceBCSMr Jones
2MathsEdExcelMs Parker
3PhysicsOCRMr Peters
4MathsAQAMs Parker
5BiologyWJECMrs Patel
6MusicAQAMs Daniels

The third table is for which students take which courses.

Student NumberCourse Number
10011
10012
10013
10024
10025
10026
10031
10032
10033
10044
10043
10045
10051
10052
10056

Finally I wrote SQL to create the tables.

CREATE TABLE students (
  student_number int UNSIGNED NOT NULL,
  student_name varchar(30) NOT NULL,
  exam_score int UNSIGNED DEFAULT NULL,
  support bool NOT NULL,
  date_of_birth date NOT NULL,
  PRIMARY KEY (student_number)
)

CREATE TABLE courses (
  course_number int UNSIGNED NOT NULL,
  course_name varchar(30) NOT NULL,
  exam_board varchar(30) DEFAULT NULL,
  teacher_name varchar(30) NOT NULL,
  PRIMARY KEY (course_number)
)

CREATE TABLE student_courses (
  student_number int UNSIGNED NOT NULL,
  course_number int UNSIGNED NOT NULL,
  PRIMARY KEY (student_number, course_number),
  FOREIGN KEY (student_number) REFERENCES students(student_number),
  FOREIGN KEY (course_number) REFERENCES courses(course_number)
)