Data Processing Revision Notes
Data Models, Entity-Relationship Diagrams (ERD), Normalization (1NF–3NF) & RDBMS
Compare hierarchical, network, relational, and object-oriented data models, read ERD cardinality, normalize unnormalized tables cleanly to 3NF, and apply primary/foreign keys in MS Access and SQL.
1. Four Classic Data Models & Relational Terminology
A Data Model defines the logical structure of a database—how records are stored, linked, and queried: 1. Hierarchical Model: Organizes data in an inverted tree (parent–child, strictly 1:N). Each child has only one parent; fast for fixed hierarchies but poor for many-to-many links. 2. Network Model: Extends the tree into a flexible graph where a child record can have multiple parents (M:N via pointer sets). 3. Relational Model (E. F. Codd, 1970): Stores data in two-dimensional tables (relations) linked by shared keys—used by MS Access, MySQL, PostgreSQL, Oracle, and SQL Server. 4. Object-Oriented Model: Stores complex data alongside methods as reusable objects (ideal for multimedia and CAD systems). Core Relational Vocabulary (High-Frequency WAEC Definitions): - Table / Relation: Collection of structured records about one entity (e.g., STUDENTS). - Tuple / Record / Row: A single complete entry in a table (one student’s details). - Attribute / Field / Column: A single property of an entity (e.g., AdmissionNo, Surname, DOB). - Domain: Set of permissible values for an attribute. Degree = number of columns; Cardinality = number of rows.
2. Database Keys & Entity-Relationship Modelling (ERD)
Keys enforce entity integrity and referential integrity across relational tables: - Primary Key (PK): Uniquely identifies every record in a table; cannot be NULL and cannot contain duplicates (e.g., StudentID or NIN). - Foreign Key (FK): An attribute in one table that references the Primary Key of another table, forming a relational link. - Candidate Key: Any minimal column (or set of columns) capable of uniquely identifying records; one becomes the PK and the others are Alternate Keys. - Composite Key: A Primary Key formed by combining two or more columns (e.g., (StudentID, SubjectCode) in an Exam Results table). ERD Standard Symbols: - Rectangle: Entity (Student, Course). - Oval (Ellipse): Attribute (underlined oval = Primary Key). - Diamond: Relationship (Enrols_In, Teaches). - Relationship Cardinality: One-to-One (1:1, e.g., School–Principal), One-to-Many (1:N, e.g., Department–Teachers), Many-to-Many (M:N, e.g., Students–Subjects—resolved in relational databases using a junction/bridge table).
3. Database Normalization Step-by-Step (UNF → 1NF → 2NF → 3NF)
Normalization is the systematic process of structuring relational tables to eliminate data redundancy and prevent insertion, update, and deletion anomalies: | Normal Form | Core Requirement | Anomaly Removed | | :--- | :--- | :--- | | 1NF (First Normal Form) | Every cell holds a single atomic (indivisible) value; no repeating groups; every row has a Primary Key. | Multi-valued cells (e.g., "Maths, Physics" in one cell). | | 2NF (Second Normal Form) | Must be in 1NF, and every non-key attribute must be fully functionally dependent on the entire composite Primary Key (no partial dependencies). | Repeating student names in a (StudentID, SubjectID) score sheet. | | 3NF (Third Normal Form) | Must be in 2NF, and no non-key attribute may depend on another non-key attribute (no transitive dependencies). | Storing DeptName and DeptHead inside Employees when DeptID → DeptHead. | Worked Example: Suppose RESULT(StudentID, SubjectID, StudentName, Score, GradePoint) has composite key (StudentID, SubjectID). - StudentName depends only on StudentID (partial dependency → violates 2NF). Split into STUDENT(StudentID, StudentName) and SCORE(StudentID, SubjectID, Score). - If TeacherOffice depends on TeacherName rather than SubjectID, move TeacherOffice to a TEACHER table to achieve 3NF.
4. MS Access Objects, SQL Queries & Examiner Traps
In Microsoft Access (the standard WAEC/NECO practical DBMS), four primary database objects are tested: 1. Tables: Store the actual raw structured data. 2. Queries: Retrieve, filter, calculate, or update specific subsets of data (via Design View or SQL). 3. Forms: User-friendly graphical interfaces for entering and editing records. 4. Reports: Formatted, printable summaries grouped with totals and headers. Essential SQL Commands: - DDL (Definition): CREATE TABLE, ALTER TABLE, DROP TABLE. - DML (Manipulation): SELECT, INSERT INTO, UPDATE, DELETE. - Example: SELECT Surname, Score FROM Students WHERE Score >= 70 ORDER BY Score DESC; Examiner Trap: A table with a single-column Primary Key that is already in 1NF is automatically in 2NF (because partial dependency can only exist with a composite key!). Never forget to check 3NF for transitive dependencies (A → B → C) even when the primary key is a single column.