Chapter 7 Normalization Chapter 13 in Textbook.

Slides:



Advertisements
Similar presentations
Normalization ABID RAFIQ LECTURE 23,24 Chapter Objectives The purpose of normailization Data redundancy and Update Anomalies Functional Dependencies.
Advertisements

B. Information Technology CMPB245: Database Design Normalization Pt. 2.
1 Database Systems: A Practical Approach to Design, Implementation and Management International Computer Science S. Carolyn Begg, Thomas Connolly Lecture.
Normalization I.
Chapter 5 Normalization Transparencies © Pearson Education Limited 1995, 2005.
Normalization II. Boyce–Codd Normal Form (BCNF) Based on functional dependencies that take into account all candidate keys in a relation, however BCNF.
Chapter 14 Advanced Normalization Transparencies © Pearson Education Limited 1995, 2005.
Lecture 12 Inst: Haya Sammaneh
Chapter 6 Normalization 正規化. 6-2 In This Chapter You Will Learn:  更動異常  How tables that contain redundant data can suffer from update anomalies ( 更動異常.
Normalization. 2 Objectives u Purpose of normalization. u Problems associated with redundant data. u Identification of various types of update anomalies.
AMANDEEP KAUR LECTURER I.T GPCG PATIALA
Normalization. Learners Support Publications 2 Objectives u The purpose of normalization. u The problems associated with redundant data.
1 Pertemuan 23 Normalisasi Matakuliah: >/ > Tahun: > Versi: >
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
Normalization Transparencies
Lecture9:Functional Dependencies and Normalization for Relational Databases Prepared by L. Nouf Almujally Ref. Chapter Lecture9 1.
CSC271 Database Systems Lecture # 28.
Reference:Dongsheng Lu’s Normalization slides Normalization.
Normalization Fundamentals of Database Systems. Lilac Safadi Normalization 2 Database Design Steps in building a database for an application: Real-world.
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
Chapter 13 Normalization. 2 Chapter 13 - Objectives u Purpose of normalization. u Problems associated with redundant data. u Identification of various.
Chapter 13 Normalization © Pearson Education Limited 1995, 2005.
Lecture 5 Normalization. Objectives The purpose of normalization. How normalization can be used when designing a relational database. The potential problems.
Chapter 13 Normalization Transparencies Last Updated: 08 th May 2011 By M. Arief
Chapter 10 Normalization Pearson Education © 2009.
ITS232 Introduction To Database Management Systems Siti Nurbaya Ismail Faculty of Computer Science & Mathematics, Universiti Teknologi MARA (UiTM), Kedah.
Lecture9:Functional Dependencies and Normalization for Relational Databases Ref. Chapter Lecture9 1.
Chapter 13 Normalization Transparencies. 2 Chapter 13 - Objectives u How to undertake process of normalization. u How to identify most commonly used normal.
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
Dr. Mohamed Osman Hegaz1 Logical data base design (2) Normalization.
Normalization Example. 2 Review Example PG4 PG16 Pno pAddress 18-Oct Apr-01 1-Oct Apr Oct-01 iDateiTime 10:00 09:00 12:00 13:00 14:00.
9/23/2012ISC329 Isabelle Bichindaritz1 Normalization.
Normalization. 2 u Main objective in developing a logical data model for relational database systems is to create an accurate representation of the data,
Normalization is a formal method involved with a series of test to help database designer to be able to identify the optimal grouping of attributes for.
11/10/2009GAK1 Normalization. 11/10/2009GAK2 Learning Objectives Definition of normalization and its purpose in database design Types of normal forms.
ITD1312 Database Principles Chapter 4C: Normalization.
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
Chapter 9 Normalization Chapter 14 & 15 in Textbook.
Chapter 8 Relational Database Design Topic 1: Normalization Chuan Li 1 © Pearson Education Limited 1995, 2005.
Chapter 4 Relational Algebra Chapter 4 in Textbook.
Normalization.
Normalization Normalization is a formal method involved with a series of test to help database designer to be able to identify the optimal grouping.
Relational Algebra Lecture 2.
Advanced Normalization
CS 3630 Database Design and Implementation
Normalization DBMS.
Normalization Dongsheng Lu Feb 21, 2003.
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
Advanced Normalization
Advanced Normalization
Normalization Lecture 7 May Aldoayan.
Chapter 14 Normalization
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
CHAPTER 5 Normalization Of Database Tables (Part II: The Process)
Normalization.
Database Normalization
Chapter 14 & Chapter 15 Normalization Pearson Education © 2009.
Normalization.
Normalization and FD.
Normalization Dongsheng Lu Feb 21, 2003.
Chapter 14 Normalization – Part I Pearson Education © 2009.
Database solutions The process of normalization Marzena Nowakowska Faculty of Management and Computer Modelling Kielce University of Technology rooms:
ITS232 Introduction To Database Management Systems
Normalization Dale-Marie Wilson, Ph.D..
Chapter 14 Normalization.
Chapter 14 Normalization.
Normalization February 28, 2019 DB:Normalization.
國立臺北科技大學 課程:資料庫系統 2015 fall Chapter 14 Normalization.
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
Presentation transcript:

Chapter 7 Normalization Chapter 13 in Textbook

How to produce a good relation schema? 1. Start with a set of relation 2. Define the functional dependencies for the relation to specify the PK 3. Transform relations to normal form Lilac Safadi Normalization

Lilac Safadi Normalization Data Redundancy STAFFBRANCH StaffNo FName LName position Salary BrnNo Address City SL21 John White Manager 30000 B005 22 Deer Rd London SG37 Ann Beech Assistant 12000 B003 B003 163 Main St 163 Main St Glasgow Glasgow SG14 David Ford Supervisor 18000 B003 B003 163 Main St 163 Main St Glasgow Glasgow SA9 Mary Howe Assistant 9000 B007 16 Arglly St Aberdeen SG5 Susan Brand Manager 24000 B003 B003 163 Main St 163 Main St Glasgow Glasgow SL41 Julie Lee Assistant 9000 B005 22 Deer Rd London Relations that have redundant data may have update anomalies (insert, modify, delete) Lilac Safadi Normalization

Lilac Safadi Normalization Data Redundancy STAFF StaffNo FName LName position Salary BrnNo SL21 John White Manager 30000 B005 SG37 Ann Beech Assistant 12000 B003 SG14 David Ford Supervisor 18000 B003 SA9 Mary Howe Assistant 9000 B007 SG5 Susan Brand Manager 24000 B003 SL41 Julie Lee Assistant 9000 B005 BRANCH BrnNo Address City B005 22 Deer Rd London B003 163 Main St Glasgow B007 16 Arglly St Aberdeen Lilac Safadi Normalization

Functional Dependencies Example 1:1 or M:1 relationship between attributes in a relation A StaffNo B is functionally dependent on A B position SL21 Manager 1:M relationship between attributes in a relation StaffNo is NOT functionally dependent on position position StaffNo Manager SL21 SG5 Lilac Safadi Normalization

Lilac Safadi Normalization StaffBranch Example Functional dependencies on StaffBranch relation StaffNo FName, Lname, position, salary, brnNo, Address, city BranchNo Address, city Address, city BranchNo BranchNo, position salary Address, city, position salary Determinants: StaffNo, BranchNo, (Address, city), (branchNo, position), and (address, city, position) Lilac Safadi Normalization

The purpose of Normalization Normalization is a bottom-up approach to database design that begins by examining the relationships between attributes. It is performed as a serious of tests on a relation to determine whether it satisfies or violates the requirements of a given normal form. Purpose: Guarantees no redundancy due to FDs Normal Forms: First Normal Form (1NF) Second Normal Form (2NF) Third Normal Form (3NF) Boyce-Codd Normal Form (BCNF) Fourth Normal Form (4NF) Fifth Normal Form (5NF) Lilac Safadi Normalization

The Process of Normalization 1NF 2NF 3NF BCNF Less vulnerable to update anomalies Stronger in format 4NF 5NF Higher Normal Form Lilac Safadi Normalization

Lilac Safadi Normalization First Normal Form (1NF) Unnormalized form (UNF): A relation that contains one or more repeating groups First normal form (1NF): A relation in which the intersection of each row and column contains one & only one value Unnormalized relation CLIENT_PROPERTY ClientNo Name PropertyNo CR76 John Key PG4 PG16 CR56 Aline Stewart PG4 PG36 PG16 Lilac Safadi Normalization

Lilac Safadi Normalization UNF 1NF Approach 1 Expand the key so that there will be a separate tuple in the original relation for each repeated attribute(s). Primary key becomes the combination of primary key and redundant value 1NF relation Disadvantage: introduce redundancy in the relation CLIENT_PROPERTY ClientNo Name PropertyNo CR76 John Key PG4 CR76 John Key PG16 CR56 Aline Stewart PG4 CR56 Aline Stewart PG36 CR56 Aline Stewart PG16 Lilac Safadi Normalization

Lilac Safadi Normalization UNF 1NF Approach 2 If the maximum number of values is known for the attribute, replace repeated attribute (PropertyNo) with a number of atomic attributes (PropertyNo1, PropertyNo2, PropertyNo3) 1NF relation Disadvantage: introduce NULL values in the relation CLIENT_PROPERTY ClientNo Name PropertyNo1 PropertyNo2 PropertyNo3 CR76 John Key PG4 PG16 NULL CR56 Aline Stewart PG4 PG36 PG16 Lilac Safadi Normalization

Lilac Safadi Normalization UNF 1NF Approach 3 Remove the attribute that violates the 1NF and place it in a separate relation along with the primary key PROPERTY CLIENT ClientNo Name PropertyNo ClientNo CR76 CR76 John Key PG4 CR76 PG16 CR56 Aline Stewart CR56 PG4 1NF relation CR56 PG36 CR56 PG16 1NF relation Lilac Safadi Normalization

Full Functional Dependency If A and B are attributes of a relation B is fully functionally dependent on A if B is functionally dependent on A, but not on any proper set of A B is partial functional dependent on A if some attributes can be removed from A & the dependency still holds StaffNo, Sname BranchNo Partial dependency ClientNo, PropertyNo RentDate Full dependency Lilac Safadi Normalization

Second Normal Form (2NF) Second normal form (2NF): A 1NF relation in which every attribute is fully nontrivial functionally dependent on the PK.non-prime attributes fully dependent on PK. Applies to relations with composite primary keys & partial dependencies 1NF relation CLIENT_RENTAL ClientNo PropertyNo cName Address RentStart RentFinish Rent OwnerNo OName Lilac Safadi Normalization

Lilac Safadi Normalization 1NF 2NF 1. Start with 1NF relation 2. Find the FDs of a relation 3. Test the FDs whose determinant attribute is part of the PK Lilac Safadi Normalization

Lilac Safadi Normalization 1NF 2NF CLIENT_RENTAL ClientNo PropertyNo cName pAddress RentStart RentFinish Rent OwnerNo OName (ClientNo, PropertyNo) PK ClientNo, PropertyNo RentStart, RentFinish Full Dependency ClientNo CName Partial Dependency PropertyNo Paddress, Rent, OwnerNo, Oname Partial Dependency ClientNo, RentStart PropertyNo, pAddress, RentFinish, Rent, OwnerNo, Oname PropertyNo, RentStart ClientNo, cName, RentFinish Lilac Safadi Normalization

Lilac Safadi Normalization 1NF 2NF 3. Remove partial dependencies by placing the functionally dependent attributes in a new relation along with a copy of their determinants 2NF relation 2NF relation 2NF relation CLIENT RENTAL ClientNo cName ClientNo PropertyNo RentStart RentFinish PROPERTY_OWNER PropertyNo pAddress Rent OwnerNo OName Lilac Safadi Normalization

Transitive Dependency A, B, C are attributes of a relation, such that If A B and B C, then C is transitively dependent on A via B Provided A is NOT functionally dependent on B or C (nontrivial FD) Example StaffNo BranchNo , BranchNo Address StaffNo Address Lilac Safadi Normalization

Lilac Safadi Normalization Third Normal Form (3NF) Third normal form (3NF): A 2NF relation in which NO non-prime attribute is transitively dependent on the PK 3NF relation 3NF relation 2NF relation CLIENT RENTAL ClientNo cName ClientNo PropertyNo RentStart RentFinish PROPERTY_OWNER PropertyNo pAddress Rent OwnerNo OName Lilac Safadi Normalization

Lilac Safadi Normalization 2NF 3NF 1. Identify the PK in the 2NF relation 2. Identify FDs in this relation 3. If transitive dependencies exist, place transitively dependent attributes in a new relation along with a copy of their determinants 3NF relation 3NF relation OWNER PROPERTY_FOR_RENT OwnerNo OName PropertyNo pAddress rent OwnerNo Lilac Safadi Normalization

General Definition of 2NF & 3NF Second normal form (2NF): A 1NF relation in which every non-primary-key attribute is fully functionally dependent on the CK Third normal form (3NF): A 2NF relation in which NO non-primary-key attribute in a nontrivial FD is transitively dependent on the CK Lilac Safadi Normalization

Boyce-Codd Normal Form (BCNF) Boyce-Codd normal form (3NF): A 3NF relation in which every determinant in a nontrivial FD is a CK Difference between 3NF & BCNF: A B 3NF allows A NOT CK BCNF insists on A is a CK Potential to violate BCNF may occur in a relation that: Contain two (or more) composite CKs CKs overlap. (at least one attribute in common) Lilac Safadi Normalization

Boyce-Codd Normal Form (BCNF) 3NF but not BCNF Lilac Safadi Normalization

Lilac Safadi Normalization 3NF BCNF 1. Examine FDs for a relation 2. If determinant is NOT a CK, decompose relation into 2 relations CLIENT_INTERVIEW ClientNo Int_Date Int_Time StaffNo RoomNo ClientNo, Int_Date Int_Time, StaffNo, RoomNo StaffNo, Int_Date, Int_Time ClientNo RoomNo, Int_Date, Int_Time StaffNo, ClientNo StaffNo, Int_Date RoomNo Lilac Safadi Normalization

Lilac Safadi Normalization 3NF BCNF 3. Remove non-CK dependencies by placing the functionally dependent attributes in a new relation BCNF relation BCNF relation STAFF_ROOM INTERVIEW ClientNo Int_Date RoomNo ClientNo Int_date Int_time StaffNo Lilac Safadi Normalization

Lilac Safadi Normalization Review Example STAFF_PROPERTY_INSPECTION Pno pAddress iDate iTime comments StaffNo sName CarReg PG4 PG16 Lawrence St, Glasgow 5 Novar Dr., 18-Oct-00 22-Apr-01 1-Oct-01 24-Oct-01 10:00 09:00 12:00 13:00 14:00 Replace crockery Good order Damp rot Replace carpet Good condition SG37 SG14 Ann David M23JGR M53HDR N72HFR Unnormalized relation Lilac Safadi Normalization

Lilac Safadi Normalization UNF 1NF STAFF_PROPERTY_INSPECTION Pno pAddress iDate iTime comments StaffNo sName CarReg PG4 PG16 Lawrence St, Glasgow Lawrence St,Glasgow 5 Novar Dr., Glasgow 18-Oct-00 22-Apr-01 1-Oct-01 24-Oct-01 10:00 09:00 12:00 13:00 14:00 Replace crockery Good order Damp rot Replace carpet Good condition SG37 SG14 Ann David M23JGR M53HDR N72HFR 1NF Lilac Safadi Normalization

Lilac Safadi Normalization 1NF 2NF STAFF_PROPERTY_INSPECTION Pno iDate pAddress iTime comments StaffNo sName CarReg Pno, iDate iTime, comments, StaffNo, Sname, CarReg Pno pAddress Partial Dependency StaffNo Sname iDate, StaffNo CarReg iDate, iTime, CarReg Pno, pAddress, comments, StaffNo, Sname iDate, iTime, StaffNo Pno, pAddress, Comments Lilac Safadi Normalization

Lilac Safadi Normalization 1NF 2NF PROPERTY_INSPECTION Pno iDate iTime comments StaffNo sName CarReg 2NF PROPERTY Pno pAddress 2NF Pno, iDate iTime, comments, StaffNo, Sname, CarReg StaffNo Sname Transitive Dependency iDate, StaffNo CarReg iDate, iTime, CarReg Pno, comments, StaffNo, Sname iDate, iTime, StaffNo Pno, comments Lilac Safadi Normalization

Lilac Safadi Normalization 2NF 3NF PROPERTY_INSPECTION Pno iDate iTime comments StaffNo CarReg 3NF STAFF StaffNo sName 3NF PROPERTY(Pno, pAddres) STAFF(StaffNo, sName) PROPERTY_INSPECT(Pno, iDate, iTime, comments, staffNo, CarReg) Lilac Safadi Normalization

Lilac Safadi Normalization 3NF BCNF PROPERTY_INSPECTION Pno iDate iTime comments StaffNo CarReg 3NF Pno, iDate iTime, comments, staffNo, CarReg) StaffNo, iDate carReg CarReg, iDate, iTime pno, comments, staffNo StaffNo, iDate, iTime pno, comments STAFF_CAR(StaffNo, iDate, CarReg) PROPERTY_INSPECT(pno, iDate, iTime, comments, StaffNo, CarReg) Lilac Safadi Normalization

Multi-Valued Dependency (MVD) Represents a dependency between attributes A, B, C in a relation, such that for each value of A, there is a set of values for B and a set of values of values for C. However, the set of values for B & C are independent of each others. Denoted by: A B, A C Example BranchNo SName, BranchNo OName BRANCH_STAFF_OWNER BranchNo SName OName B003 Ann David Carol Tina Lilac Safadi Normalization

Lilac Safadi Normalization Trivial MVD A B trivial MVD if: B  A OR A  B = R Lilac Safadi Normalization

Fourth Normal Form (4NF) Fourth normal form (4NF): A BCNF relation with NO nontrivial MVD BCNF relation BRANCH_STAFF_OWNER BranchNo SName OName B003 Ann David Carol Tina Lilac Safadi Normalization

Lilac Safadi Normalization BCNF 4NF Start with a BCNF relation Examine FDs for a relation If nontrivial MVD exists, remove the MVD by placing the attributes in a new relation along with a copy of their determinant 4NF 4NF BRANCH_STAFF BRANCH_OWNER BranchNo SName BranchNo OName B003 Ann David B003 Carol Tina Lilac Safadi Normalization

Lossless-Join Dependency A property of decompostion, which ensures that no spurious tuples are generated when relations are reunited through a natural join operation Objectives: Preserve all the data in the original relation Does not result in the creation of additional spurious tuples Lilac Safadi Normalization

Lilac Safadi Normalization Join Dependency A, B, .., Z attributes in relation R satisfies join dependency if Every legal value of R is equal to the join of its projections on A, B, .., Z Lilac Safadi Normalization

Lilac Safadi Normalization Fifth Normal Form (5NF) Fifth normal form (5NF): A relation with no join dependency PROPERTY_ITEM_SUPPLIER PropertyNo Description SupplierNo PG4 PG16 Bed Chair S1 S2 Lilac Safadi Normalization

Lilac Safadi Normalization 4NF 5NF PROPERTY_ITEM ITEM_SUPPLIER PROPERTY_ITEM PropertyNo Description Description SupplierNo PropertyNo SupplierNo PG4 PG16 Bed Chair Bed Chair S1 S2 PG4 PG16 S1 S2 PROPERTY_ITEM_SUPPLIER PropertyNo Description SupplierNo PG4 PG16 Bed Chair S1 S2 Original PROPERTY_ITEM_SUPPLIER Lilac Safadi Normalization