CSC 282 · Database Programming
Our notes
2 min readEntity-relationship (ER) modelling
- Entity: a thing we keep data about (Student, Course, Lecturer).
- Attribute: a property (Surname, Units).
- Relationship: how entities are linked (Student registers for Course), with cardinality (1:1, 1:N, M:N) and participation (must every student register for a course? then participation is total).
In Chen notation entities are rectangles, attributes ovals, relationships diamonds; crow's-foot notation draws the "many" end as a three-pronged foot.
From ER diagram to tables
- Each entity → a table, its identifier → primary key.
- 1:N relationship → foreign key on the many side.
- M:N relationship → a new table with both keys (plus attributes of the relationship, such as Score).
- 1:1 → a foreign key on either side (often the side with total participation).
Why normalise
Badly designed tables cause anomalies:
- Insertion: cannot add a new course until a student takes it.
- Update: a course title stored in 300 rows must be changed in all 300.
- Deletion: deleting the last student in a course loses the course's title.
Worked example
Unnormalised: Registration(MatricNo, Name, Dept, DeptHead, Courses: [Code, Title, Units, Score]).
First normal form (1NF): no repeating groups; every cell holds one value. Make one row per student per course:
R(MatricNo, Name, Dept, DeptHead, Code, Title, Units, Score), key (MatricNo, Code).
Second normal form (2NF): 1NF and no partial dependency (a non-key column depending on only part of a composite key).
- Name, Dept, DeptHead depend on MatricNo alone.
- Title, Units depend on Code alone.
Split: Student(MatricNo, Name, Dept, DeptHead), Course(Code, Title, Units), Result(MatricNo, Code, Score).
Third normal form (3NF): 2NF and no transitive dependency (a non-key column depending on another non-key column).
- DeptHead depends on Dept, which depends on MatricNo.
Split: Student(MatricNo, Name, Dept), Department(Dept, DeptHead).
Final tables: Student, Department, Course, Result. Each fact is stored once.
Memory aid: every non-key attribute depends on "the key, the whole key, and nothing but the key".
Beyond 3NF
Boyce-Codd normal form (BCNF) requires every determinant to be a candidate key; it fixes rare cases 3NF misses. Designers sometimes denormalise on purpose for speed in reporting, accepting the redundancy.
Exams usually ask
- Draw an ER diagram for a scenario (library, hospital, hostel allocation).
- Normalise a table to 3NF, showing each step and the dependencies.
- Explain update, insertion and deletion anomalies.
Common mistake
Stopping at 1NF because the table "looks neat". Check every non-key column: does it depend on the whole key and only on the key?
Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.
Read
-
Entity–relationship model
(opens en.wikipedia.org in a new tab)
Wikipedia, Entity–relationship model, CC BY-SA 4.0 · licence
-
Database normalization
(opens en.wikipedia.org in a new tab)
Wikipedia, Database normalization, CC BY-SA 4.0 · licence
-
NOUN CIT 304: Data Management
NOUN course book (PDF, about 6.9 MB: best on Wi-Fi). Files, databases, the relational model and SQL.
(opens nou.edu.ng in a new tab)
Watch
-
Best pick Learn Database Normalization - 1NF, 2NF, 3NF, 4NF, 5NF
29 min · ≈ 131 MB · about ₦74
(opens youtube.com in a new tab)
-
Database Design Process
11 min · ≈ 50 MB · about ₦28
(opens youtube.com in a new tab)
-
Entity Relationship Diagram (ERD) Tutorial - Part 1
6 min · ≈ 27 MB · about ₦15
(opens youtube.com in a new tab)
-
DBMS - Entity Relationship Diagram
5 min · ≈ 23 MB · about ₦13
(opens youtube.com in a new tab)
-
Entity Relationship Diagrams - Database Design and the E-R Model - Database Management System
43 min · ≈ 194 MB · about ₦109
(opens youtube.com in a new tab)
We link to free material and never copy it. Every link was opened by our team before it went up; video data is a rough guide at 360p.