Normalization
Normalization
o Main objective in developing a logical data model for relational database systems is to create an accurate representation of the data, its relationships, and constraints. o To achieve this objective, we must identify a suitable set of relations => The Normalization Technique o Developed by E.F. Codd (1972).
Normalization
Normalization - 1
Normalization - 2
Normalization
o Often performed as a series of tests on a relation to determine whether it satisfies or violates the requirements of a given normal form. o 4 most commonly used normal forms are first (1NF), second (2NF), third (3NF) and Boyce-Codd (BCNF) normal forms. o Based on functional dependencies among the attributes of a relation. o A relation can be normalized to a specific form to prevent the possible occurrence of update anomalies.
Normalization - 3
Data Redundancy
o Major aim of relational database design is to group attributes into relations to minimize data redundancy and reduce file storage space required by base relations.
Normalization - 4
Data Redundancy
Update Anomalies
o Relations that contain redundant information may potentially suffer from update anomalies. o Types of update anomalies include Insertion Deletion (eg. in the Staff_Branch relation, for a particular branch, removal of the last member of staff => lost of branch information) Modification
o Staff_Branch relation has redundant data; the details of a branch are repeated for every member of staff.
Normalization - 5
Normalization - 6
Functional Dependency
Functional Dependency: o Main concept associated with normalization. o Functional Dependency Describes the relationship between attributes in a relation. For example, if A and B are attributes of relation R, B is functionally dependent on A (denoted A -> B), if each value of A in R is associated with exactly one value of B in R.
Functional Dependency
Diagrammatic representation:
Normalization - 7
Normalization - 8
Functional Dependency
Normalization - 9
Normalization - 10
Normalization - 11
Normalization - 12
Normalization - 13
Normalization - 14
Example - A Report
Example - UNF
Normalization - 15
Normalization - 16
Normalization - 18
Normalization - 19
Normalization - 20
Primary key: Customer_No + Property_No Full Functional Dependency: (Customer_No+Property_No)->(RentStart, RentFinish) Partial Dependency: (Customer_No+Property_No)->Cname (Customer_No+Property_No)->(Paddress, Rent, Owner_No, Oname)
Normalization - 21
Normalization - 22
Normalization - 24
Process of Decomposition
Normalization - 25
Normalization - 26
3NF to BCNF
o Identify all candidate keys in the relation. o Identify all functional dependencies in the relation. o If functional dependencies exists in the relation where their determinants are not candidate keys for the relation, remove the functional dependencies by placing them in a new relation along with a copy of their determinant.
Normalization - 28
Everyday a staff is allocated a room only. Staff may share rooms. Clients maybe interviewed again.
(Client_No, Interview_Date) -> (Interview_Time, Staff_No, Room_No) (Staff_No, Interview_Date, Interview_Time) -> Client_No (Room_No, Interview_date, Interview_Time) -> Staff_No, Client_No (Staff_No, Interview_Date) -> Room_No
Normalization - 29 Normalization - 30
Example
UNF
1NF
2NF
3NF
BCNF
Normalization - 31
Normalization - 32
Example BCNF
Prop (Property_No,Paddress) Staff (Staff_No, Sname) Inspection (Property_No, IDate, ITime, Comments, Staff_No) Staff_Car (Staff_No, IDate, Car_Reg)
Process of Decomposition
Normalization - 37
Normalization - 38