IS 230Lecture 8Slide 1 Normalization Lecture 9. IS 230Lecture 8Slide 2 Lecture 8: Normalization 1. Normalization 2. Data redundancy and anomalies 3. Spurious.

Slides:



Advertisements
Similar presentations
Functional Dependencies and Normalization for Relational Databases
Advertisements

Defined by Edgar Codd in 1970 Defined by Edgar Codd in 1970 Considered ingenious but impractical Considered ingenious but impractical Conceptually simple.
NORMALIZATION. Normalization Normalization: The process of decomposing unsatisfactory "bad" relations by breaking up their attributes into smaller relations.
Chapter 3 Notes. 3.1 Functional Dependencies A functional dependency is a statement that – two tuples of a relation that agree on some particular set.
Ch 10, Functional Dependencies and Normal forms
Functional Dependencies and Normalization for Relational Databases.
Ms. Hatoon Al-Sagri CCIS – IS Department Normalization.
Functional Dependencies and Normalization for Relational Databases
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Basics of Functional Dependencies and Normalization for Relational.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
1 Normalization Chapter What it’s all about Given a relation, R, and a set of functional dependencies, F, on R. Assume that R is not in a desirable.
METU Department of Computer Eng Ceng 302 Introduction to DBMS Functional Dependencies and Normalization for Relational Databases by Pinar Senkul resources:
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
Chapter 8 Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Ch 7: Normalization-Part 2 Much of the material presented in these slides was developed by Dr. Ramon Lawrence at the University of Iowa.
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 10 Functional Dependencies and Normalization for Relational Databases.
AL-MAAREFA COLLEGE FOR SCIENCE AND TECHNOLOGY INFO 232: DATABASE SYSTEMS CHAPTER 6 NORMALIZATION FOR RELATIONAL DATABASES Instructor Ms. Arwa Binsaleh.
Functional Dependencies
NormalizationNormalization Chapter 4. Purpose of Normalization Normalization  A technique for producing a set of relations with desirable properties,
Announcements Read 5.8 – 5.13 for Monday Project Step 3, due Monday 10/18 Homework 4, due Friday 10/15 – by (or turn in Monday in class)
King Saud University College of Computer & Information Sciences Computer Science Department CS 380 Introduction to Database Systems Functional Dependencies.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Normalization for Relational Databases.
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
Chapter 6 - Relational Database Design First Normal Form Pitfalls in relational database design Functional Dependencies Armstrong Axioms 2 nd, 3 rd, BCNF,
DatabaseIM ISU1 Chapter 10 Functional Dependencies and Normalization for RDBs Fundamentals of Database Systems.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Topic 10 Functional Dependencies and Normalization for Relational Databases Faculty of Information Science and Technology Mahanakorn University of Technology.
Schema Refinement and Normal Forms 20131CS3754 Class Notes #7, John Shieh.
Instructor: Churee Techawut Functional Dependencies and Normalization for Relational Databases Chapter 4 CS (204)321 Database System I.
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Chapter 4 Normalization.
Top-Down Database Design Mini-world Requirements Conceptual schema E1 E2 R Relation schemas ?
Functional Dependencies and Normalization for Relational Databases.
By Abdul Rashid Ahmad. E.F. Codd proposed three normal forms: The first, second, and third normal forms 1NF, 2NF and 3NF are based on the functional dependencies.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 15 Basics of Functional Dependencies and Normalization for Relational.
Chapter Functional Dependencies and Normalization for Relational Databases.
CSE314 Database Systems Basics of Functional Dependencies and Normalization for Relational Databases Doç. Dr. Mehmet Göktürk src: Elmasri & Navanthe 6E.
1 Functional Dependencies and Normalization Chapter 15.
Normalization Sept. 2012ACS-3902 Yangjun Chen1 Outline: Normalization Chapter 14 – 3rd ed. (Chap. 10 – 4 th, 5 th ed.; Chap. 6, 6 th ed.) Redundant information.
Lecture 8: Database Concepts May 4, Outline From last lecture: creating views Normalization.
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
Design Process - Where are we?
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.
Database Design FUNCTIONAL DEPENDENCES NORMAL FORMS D. Christozov / G.Tuparov INF 280 Database Systems: DB design: Normal Forms 1.
Chapter 7 Functional Dependencies Copyright © 2004 Pearson Education, Inc.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Ch 7: Normalization-Part 1
Al-Imam University Girls Education Center Collage of Computer Science 1 st Semester, 1432/1433H Chapter 10_part 1 Functional Dependencies and Normalization.
Al-Imam University Girls Education Center Collage of Computer Science 1 nd Semester, 1432/1433H Chapter 10_part2 Functional Dependencies and Normalization.
Chapter 15 1 Functional Dependencies and Normalization for Relational Databases تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
Chapter 14 Functional Dependencies and Normalization Informal Design Guidelines for Relational Databases –Semantics of the Relation Attributes –Redundant.
Functional Dependencies and Normalization for Relational Databases تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في ذلك. حيث المرجع.
1 Normalization David J. Stucki. Outline Informal Design Guidelines Normal Forms  1NF  2NF  3NF  BCNF  4NF 2.
COP 6726: New Directions in Database Systems
Functional Dependency and Normalization
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Normal forms First Normal Form (1NF) Second Normal Form (2NF)
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Functional Dependencies and Normalization
Sridhar Narayan Normalization Sridhar Narayan
Normalization.
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Normalization February 28, 2019 DB:Normalization.
Chapter Outline 1 Informal Design Guidelines for Relational Databases
Presentation transcript:

IS 230Lecture 8Slide 1 Normalization Lecture 9

IS 230Lecture 8Slide 2 Lecture 8: Normalization 1. Normalization 2. Data redundancy and anomalies 3. Spurious information 4. Functional dependencies 5. Normalization first normal form second normal form third normal form BCNF normal form 6. Normalization Methodology: Example

IS 230Lecture 8Slide 3 1. Normalization A technique for producing a set of relations with desirable properties, given the data requirements of the applications

IS 230Lecture 8Slide 4 2. Data redundancy and anomalies Emp-Dept relation Insertion How do we insert a new department with no employees yet? (keys?) Entering employees is difficult as department information must be entered correctly. Deletion What happens when we delete CC's data - do we lose department 6? Modification If we change the manager of department 5, we must change it for tuples with Dept# = 5.

IS 230Lecture 8Slide 5 3. Spurious information Avoid breaking up relations in such a way that spurious information is created may be broken into: Joining them back together, we get NEW TUPLES!

IS 230Lecture 8Slide 6 4. Functional dependencies Formal concepts that may be used to exhibit “goodness” and “badness” of individual relational schemas, and describe relationships between attributes Examples of Functional Dependency Name, DateOfBirth, Dept  all depend on NI  Dname & Manager depend on Dept  ProjLocation depends on ProjName.

IS 230Lecture 8Slide 7 Functional Dependence An attribute, X, of a relation is functionally dependent on attributes A, B,..., N if the same values of A,..., N are always associated with the same value of X {A,…,N}  X A,..., N is called the determinant of the functional dependency

IS 230Lecture 8Slide 8 Full Functional Dependency X fully depends on A, …, N if it is not dependent on any subset of A,..., N; otherwise we talk of partial dependency e.g. age is dependent on NI  and Name but only fully dependent on NI .

IS 230Lecture 8Slide 9 5. Normalization Process taking a set of relations and decomposing them into more relations satisfying some criteria. Decomposition essentially a series of projections so that the original data can be reconstituted using joins. Normal form form of the relations which satisfy the criteria

IS 230Lecture 8Slide First Normal Form (1) A relation is in first normal form (1NF) if all values are atomic, i.e. single values - small strings and numbers. Identify and remove repeating groups (multi-valued attributes)

IS 230Lecture 8Slide 11 First Normal Form (2) DEPARTMENT Two ways of normalising this: Have a tuple for each location of each department: Have a separate relation for (Dnumber, Locations) pairs: The latter is better as it avoids redundancy.

IS 230Lecture 8Slide 12 First Normal Form (3) Example of composite attribute: Room is not atomic Room includes Deptname and Room#

IS 230Lecture 8Slide Second Normal Form By the definition of the primary key, every other attribute is functionally dependent on it. If all the other attributes are fully functionally dependent then the relation is in Second Normal Form (2NF). Clearly, any relation with a single primary key will be 2NF. If there are two primary key attributes, A & B, then each other attribute is either dependent on A alone; dependent on B alone; or dependent on both. 2NF Normal consists of creating a separate relation for each of the three cases.

IS 230Lecture 8Slide 14 Example of 2NF decomposition EMP_PROJ(SSN, Pnumber, Hours, Ename, Pname, Ploc) SSNPnumber Hours EnamePnamePloc Decomposition into three 2NF relations: Work(SSN,Pnumber,Hours) EMP(SSN,Ename) Project(Pnumber,Pname,Ploc) SSN  Ename Pnumber  Pname,Ploc SSN, Pnumber  Hours

IS 230Lecture 8Slide Third Normal Form Third Normal Form eliminates transitive dependencies - i.e. those dependencies which hold only because of some intermediary. An attribute is transitively dependent on the primary key if there is some other attribute which is dependent on and which is, in turn, dependent on the key. Dname is dependent on NI , but only because it is dependent on Dnumber which is, in turn, dependent on NI . Non-3NF relations are likely to hold redundant information. A relation is in 3NF if for any pair of attribute A & B such that A  B, there is no attribute such that A  X and X  B. Normalizing this would create:

IS 230Lecture 8Slide 16 Example of 3NF decomposition EMP_DEPT(SSN, Ename, Bdate, Address, Dnum, Dname, Dman) Ename Bdate AddressDnum Dname Dman SSN Decomposition into two 3NF relations: EMPLOYEE(SSN, Ename, Bdate, Address, Dnum) DEPT(Dnum, Dname, Dman) SSN  Ename, Bdate, Address, Dnum Dnum  Dname, Dman

IS 230Lecture 8Slide 17 General Definitions of Normal Forms

IS 230Lecture 8Slide Boyce-Codd Normal Form Every relation in BCNF is also in 3NF Relation in 3NF is not necessarily in BCNF Nontrivial FD means not trivial FD A trivial functional dependency X  Y is one in which Y is a subset of X Example: A, B  B is a trivial FD Most relation schemas that are in 3NF are also in BCNF

IS 230Lecture 8Slide 19 Example of not BCNF The following is not in BCNF: bor_loan = (customer_id, loan_number, amount) The following is a functional dependency that may hold: loan_number  amount but loan_number is not a superkey of bor_loan We decompose into two relations: R1=(customer_id, loan_number) R2=(loan_number, amount) R1 and R2 are in BCNF

IS 230Lecture 8Slide 20 R=(A, B, C, D, E, F) A, B  D B  E (not in BCNF) D  F (not in 3NF)

IS 230Lecture 8Slide 21 Normalization Methodology: Example Consider the following description of a company: The company is divided into departments. Each department is identified by its department number. A department has a name and a manager (an employee). The employees of the company are identified by their National Insurance number. An employee has a name, an address, an age, and work in one department only. An employee is supervised by several supervisors (employees), and a supervisor can supervise several employees (supervisees). An employee can have dependents, where each dependent is described by his/her name and age. The company has a number of running projects. A project is identified by its project number. A project has also a name and a description. Several employees can work on a project, and an employee can work on several projects, each a fixed number of hours.

IS 230Lecture 8Slide 22 AB141537AB Functional dependencies An attribute, X, of a relation is functionally dependent on attributes A, B,..., N if the same values of A,..., N are always associated with the same value of X {A,…,N}  X Example A  B does NOT hold, B  A does hold

IS 230Lecture 8Slide Functional dependencies (Cont.) The company is divided into departments. Each department is identified by its department number. A department has a name and a manager (an employee). Dnumber  Dname, Manager The employees of the company are identified by their National Insurance number. An employee has a name, an address, an age, and work in one department only. NI  Ename, Address, Eage, Dnumber

IS 230Lecture 8Slide Functional dependencies (Cont.) An employee is supervised by several supervisors (employees), and a supervisor can supervise several employees (supervisees). NI  Supervisor (is not a valid functional dependency since an employee can have several supervisors) An employee can have dependents, where each dependent is described by his/her name and age. NI, DepName  DepAge

IS 230Lecture 8Slide Functional dependencies (Cont.) The company has a number of running projects. A project is identified by its project number. A project has also a name and a description. Pno  Pname, Description Several employees can work on a project, and an employee can work on several projects, each a fixed number of hours. Pno, NI  Hours

IS 230Lecture 8Slide All Functional dependencies Dnumber  Dname, Manager NI  Ename, Address, Eage, Dnumber NI, DepName  DepAge Pno  Pname, Description Pno, NI  Hours The Universal Relation: U(Dnumber, Dname, Manager, NI, Ename, Address, Eage, Pno, Pname, Description, DepName, DepAge, Hours, Supervisor)

IS 230Lecture 8Slide The Primary key What is the primary key? (Dnumber, NI, Pno, DepName)? Supervisor must be part of the primary key because it is a multivalued attribute DepName must be part of the primary key since there can be several dependents to an employee Dnumber is not part of the primary key since it can be derived from NI Thus the primary key is (NI, Pno, DepName, Supervisor)

IS 230Lecture 8Slide Is U in 1NF? A relation is in first normal form (1NF) if all values are atomic, i.e. single values Supervisor is a multivalued attribute, hence U is not in 1NF To remove the multivalued attribute, the relation U is decomposed as follows U1(Dnumber, Dname, Manager, NI, Ename, Address, Eage, Pno, Pname, Description, DepName, DepAge, Hours) Supervise(NI, Supervisor)

IS 230Lecture 8Slide Is U in 2NF? A relation is in Second Normal Form (2NF) if all the attributes are fully functionally dependent on the primary key. A relation with a single primary key is in 2NF. Supervise is in 2NF U1 is not in 2NF because some attributes are partially functionally dependent on the primary key (e.g. DepAge, Ename, etc). We decompose U1 into the following 2NF relations: Dept_Emp(Dnumber, Dname, Manager, NI, Ename, Address, Eage) Dependent(NI, DepName, DepAge) Project(Pno, Pname, Description) Work(NI, Pno, Hours)

IS 230Lecture 8Slide Is the previous decomposition in 3NF? A relation is in 3NF if for any pair of attributes A & B such that A  B, there is no attribute such that A  X and X  B Supervise is in 3NF Among the above relations, only Dept_Emp is not in 3NF, since it has transitive dependencies (e.g. NI  Dnumber  Dname). We therefore decompose the relation into the following two relations, which are in 3NF: Department(Dnumber, Dname, Manager) Employee(NI, Ename, Address, Eage, Dnumber)

IS 230Lecture 8Slide Complete Schema in 3NF Department(Dnumber, Dname, Manager) Employee(NI, Ename, Address, Eage,Dnumber) Dependent(NI, DepName, DepAge) Project(Pno, Pname, Description) Work(NI, Pno, Hours) Supervise(NI, Supervisor)

IS 230Lecture 8Slide 32 End of Chapter