4 TH NORMAL FORM & Lossless Decomposition By: Karen McVay CS 157B.

Slides:



Advertisements
Similar presentations
5 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Advertisements

Defined by Edgar Codd in 1970 Defined by Edgar Codd in 1970 Considered ingenious but impractical Considered ingenious but impractical Conceptually simple.
1/22/20091 Study the methods of first, second, third, Boyce-Codd, fourth and fifth normal form for relational database design, in order to eliminate data.
Boyce-Codd NF Takahiko Saito Spring 2005 CS 157A.
Normalization What is it?
NORMALIZATION FIRST NORMAL FORM (1NF): A relation R is in 1NF if all attributes have atomic value = one value for an attribute = no repeating groups =
Normalisation The theory of Relational Database Design.
Jump to first page Normalization Jump to first page Topics n Why normalization is needed n What causes anomalies n What the 4 normal forms are n How.
Chapter 8 Normal Forms Based on Functional Dependencies Deborah Costa Oct 18, 2007.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
1 Database Design Theory Which tables to have in a database Normalization.
4 Normal Form Nathanael Chow CS 157A Fall 2006 Dr. Lee.
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
4 TH NORMAL FORM By: Karen McVay. REVIEW OF NFs 1NF  All values of the columns are atomic. That is, they contain no repeating values. 1NF  All values.
Winter 2007ACS Ron McFadyen1 Multivalued Dependencies and 4NF Some relations can exist that are in BCNF but they have redundant data and have update.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 5 The Relational Model and Normalization.
Normalization II. Boyce–Codd Normal Form (BCNF) Based on functional dependencies that take into account all candidate keys in a relation, however BCNF.
Introduction to Schema Refinement
Normalization B Database Systems Normal Forms Wilhelm Steinbuss Room G1.25, ext. 4041
Normalization Amit Bhawnani & Nimesh Shah. What is normalization We need some formal measure of why one grouping of attributes into a relational schema.
Normalization of relational database Data redundance Second Normal Form Third Normal Form Forth Normal Form.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Lecture 12 Inst: Haya Sammaneh
Avoiding Database Anomalies
NormalizationNormalization Chapter 4. Purpose of Normalization Normalization  A technique for producing a set of relations with desirable properties,
Concepts of Database Management, Fifth Edition
King Saud University College of Computer & Information Sciences Computer Science Department CS 380 Introduction to Database Systems Functional Dependencies.
Normalization. Learners Support Publications 2 Objectives u The purpose of normalization. u The problems associated with redundant data.
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
DatabaseIM ISU1 Chapter 10 Functional Dependencies and Normalization for RDBs Fundamentals of Database Systems.
SALINI SUDESH. Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of.
Schema Refinement and Normal Forms 20131CS3754 Class Notes #7, John Shieh.
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
Chapter 7 1 Database Principles Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that.
CS143 Review: Normalization Theory Q: Is it a good table design? We can start with an ER diagram or with a large relation that contain a sample of the.
1 Normalization, Roberts’s Rules and Introduction to Data Modeling CSCI 6442.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
Further Normalization I
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.
1 Functional Dependencies and Normalization Chapter 15.
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
Design Process - Where are we?
Dr. Mohamed Osman Hegaz1 Logical data base design (2) Normalization.
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.
CS 405G: Introduction to Database Systems Instructor: Jinze Liu Fall 2009.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
CS 405G: Introduction to Database Systems Database Normalization.
11/10/2009GAK1 Normalization. 11/10/2009GAK2 Learning Objectives Definition of normalization and its purpose in database design Types of normal forms.
NormalisationNormalisation Normalization is the technique of organizing data elements into records. Normalization is the technique of organizing data elements.
Objectives of Normalization  To create a formal framework for analyzing relation schemas based on their keys and on the functional dependencies among.
Database Architecture Normalization. Purpose of Normalization A technique for producing a set of relations with desirable properties, given the data requirements.
NORMALIZATION Handout - 4 DBMS. What is Normalization? The process of grouping data elements into tables in a way that simplifies retrieval, reduces data.
Logical Database Design and Relational Data Model Muhammad Nasir
SLIDE 1IS 257 – Fall 2006 Normalization Normalization theory is based on the observation that relations with certain properties are more effective.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
4TH NORMAL FORM By: Karen McVay.
COP 6726: New Directions in Database Systems
Normalization Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 19.
Functional Dependency and Normalization
Advanced Normalization
A brief summary of database normalization
Normalization.
4 Normal Form.
CS 405G: Introduction to Database Systems
Normalization February 28, 2019 DB:Normalization.
Sampath Jayarathna Cal Poly Pomona
NORMALIZATION FIRST NORMAL FORM (1NF):
Chapter Outline 1 Informal Design Guidelines for Relational Databases
Presentation transcript:

4 TH NORMAL FORM & Lossless Decomposition By: Karen McVay CS 157B

REVIEW OF NFs 1NF  All values of the columns are atomic. That is, they contain no repeating values. 1NF  All values of the columns are atomic. That is, they contain no repeating values. 2NF  it is in 1NF and every non-key column is fully dependent upon the primary key (avoid partial dependencies) 2NF  it is in 1NF and every non-key column is fully dependent upon the primary key (avoid partial dependencies)

REVIEW OF NF Cont… 3NF  it is in 2NF and every non-key column is non transitively dependent upon its primary key. In other words, all non-key attributes are functionally dependent only upon the primary key. 3NF  it is in 2NF and every non-key column is non transitively dependent upon its primary key. In other words, all non-key attributes are functionally dependent only upon the primary key. BCNF  A relation is in BCNF if every determinant is a candidate key. This is an improved form of third normal form. BCNF  A relation is in BCNF if every determinant is a candidate key. This is an improved form of third normal form. Determinant: an attribute on which some other attribute is fully functionally dependent

4NF and Multivalued Dependencies Some relations can exist that are in BCNF but they have redundant data and have update anomalies The next highest normal form is 4NF 4NF is based on multivalued dependencies

Multivalued Dependencies Consider a relation R with attributes X, Y, Z where X, Y, Z are sets of attributes The multivalued dependency, X Y, exists if when two tuples exist having the same X values: T1(x, y1, z1) and T2(x, y2, z2), implies the two tuples – –T4(x, y2, z1) and T3(x, y1, z2) also exist

Example Suppose we have two one-to-many relationships: Each employee may have many dependants Each employee may work on many projects For any employee, the dependents are completely independent of the projects – –For a given value of ename, the values of pname are only determined by ename and not dname – –For a given value of ename, the values of dname are only determined by ename and not pname – –So, each dname is repeated for each pname, and viceversa

Consider the relation EMP enamepnamedname EMP If (Smith, X, John) and (Smith, Y, Anna) exist, then (Smith, Y, John) and (Smith, X, Anna) exist The MVD ename pname | dname exists in EMP Note that EMP is BCNF, and there is a lot of redundancy in EMP

We might have liked to have: enamepnamedname EMP SmithX, YJohn, Anna But 1NF does not permit multivalued attributes

enamepnamedname EMP SmithXJohn SmithYAnna So, instead of : enamepnamedname EMP SmithX, YJohn, Anna We have: SmithYJohn SmithXAnna

Note that if X Y | Z exists, then R can be decomposed into (X,Y) and (R-Y) XYZ R XY Ra XZ Rb And this is a lossless decomposition Decomposing a MVD without loss of information

As ename pname | dname exists, EMP can be decomposed into enamepnamedname EMP enamepname EMPa enamedname EMPb This is a lossless decomposition

4th Normal Form A Boyce Codd normal form relation is in fourth normal form if (a) there is no multi value dependency in the relation or (b) there are multi value dependency but the attributes, which are multi value dependent on a specific attribute, are dependent between themselves.

4 th Normal Form Cont… This is best discussed through mathematical notation. Assume the following relation R(a:pk1, b:pk2, c:pk3) Recall that a relation is in BCNF if all its determinant are candidate keys, in other words each determinant can be used as a primary key. Because relation R has only one determinant (a, b, c), which is the composite primary key and since the primary is a candidate key therefore R is in BCNF.

4 th Normal Form Cont… Now R may or may not be in fourth normal form. 1. If R contains no multi value dependency then R will be in Fourth normal form. 2. Assume R has the following two-multi value dependencies: a --->> b and a --->> c In this case R will be in the fourth normal form if b and c dependent on each other. However if b and c are independent of each other then R is not in fourth normal form and the relation has to be projected to two non-loss projections.

Consider a case of class enrollment. Each student can be enrolled in one or more classes and each class can contain one or more students. Clearly, there is a many-to-many relationship between classes and students. This relationship can be represented by a Student/Class cross- reference table: {StudentID, ClassID} Example

Example Cont… The key for this table is the combination of StudentID and ClassID. To avoid violation of 2NF, all other information about each student and each class is stored in separate Student and Class tables, respectively. The key for this table is the combination of StudentID and ClassID. To avoid violation of 2NF, all other information about each student and each class is stored in separate Student and Class tables, respectively. Note that each StudentID determines not a unique ClassID, but a well-defined, finite set of values. This kind of behavior is referred to as multi-valued dependency of ClassID on StudentID. Note that each StudentID determines not a unique ClassID, but a well-defined, finite set of values. This kind of behavior is referred to as multi-valued dependency of ClassID on StudentID.

Consider another example with two many-to-many relationships, between students and classes and between classes and teachers. Consider another example with two many-to-many relationships, between students and classes and between classes and teachers. Example 2 StudentsClasses ** Also, a many-to-many relationship between students and teachers is implied. Also, a many-to-many relationship between students and teachers is implied. ClassesTeachers **

The combination of StudentID and TeacherID does not contain any additional information beyond the information implied by the student/class and class/teacher relationships. The combination of StudentID and TeacherID does not contain any additional information beyond the information implied by the student/class and class/teacher relationships. Consequentially, the student/class and class/teacher relationships are independent of each other—these relationships have no additional constraints. The following table is, then, in violation of 4NF: Consequentially, the student/class and class/teacher relationships are independent of each other—these relationships have no additional constraints. The following table is, then, in violation of 4NF: {StudentID, ClassID, TeacherID} Example 2 Cont…

As an example of the anomalies that can occur, realize that it is not possible to add a new class taught by some teacher without adding at least one student who is enrolled in this class. As an example of the anomalies that can occur, realize that it is not possible to add a new class taught by some teacher without adding at least one student who is enrolled in this class. 4 th NF and Anomalies

4 th Normal Form and anomalies Cont… Case 1: Assume the following relation: Employee (Eid:pk1, Language:pk2, Skill:pk3) No multi value dependency, therefore R is in fourth normal form. No multi value dependency, therefore R is in fourth normal form.

case 2: Assume the following relation with multi-value dependency: Employee (Eid:pk1, Languages:pk2, Skills:pk3) Eid --->> LanguagesEid --->> Skills Languages and Skills are dependent. This says an employee speak several languages and has several skills. However for each skill a specific language is used when that skill is practiced. 4th Normal Form and anomalies Cont…

Thus employee 100 when he/she teaches speaks English but when he cooks speaks French. This relation is in fourth normal form and does not suffer from any anomalies. EidLanguageSkill 100EnglishTeaching 100KurdishPolitic 100FrenchCooking 200EnglishCooking 200ArabicSinging

case 3: Assume the following relation with multi- value dependency: Employee (Eid:pk1, Languages:pk2, Skills:pk3) Eid --->> LanguagesEid --->> Skills Languages and Skills are independent. 4th Normal Form and anomalies Cont…

EidLanguageSkill 100EnglishTeaching 100KurdishPolitic 100EnglishPolitic 100KurdishTeaching 200ArabicSinging This relation is not in fourth normal form and suffers from all three types of anomalies.

Insertion anomaly: To insert row (200 English Cooking) we have to insert two extra rows (200 Arabic cooking), and (200 English Singing) otherwise the database will be inconsistent. Note the table will be as follow: EidLanguageSkill 100EnglishTeaching 100KurdishPolitics 100EnglishPolitics 100KurdishTeaching 200ArabicSinging 200EnglishCooking 200ArabicCooking 200EnglishSinging

Deletion anomaly: If employee 100 discontinue politic skill we have to delete two rows: Deletion anomaly: If employee 100 discontinue politic skill we have to delete two rows: (100 Kurdish Politic), and (100 English Politic) otherwise the database will be inconsistent. EidLanguageSkill 100EnglishTeaching 100KurdishPolitics 100EnglishPolitics 100KurdishTeaching 200ArabicSinging 200EnglishCooking 200ArabicCooking 200EnglishSinging

More anomalies Update anomaly: If employee 200 changes his skill from singing to dancing we have to make changes in more than one place. Update anomaly: If employee 200 changes his skill from singing to dancing we have to make changes in more than one place.

The relation is projected to the following two non-loss projections which are in forth normal form Emplyee_Language(Eid:pk1, Languages:pk2) EidLanguage 100English 100Kurdish 200Arabic

Emplyee_skill(Eid:pk1, Skills:pk2) EidSkill 100Teaching 100Politic 200Singing Cont…

References Functional Dependency (Normalization) ny/files/Normalization.htm ny/files/Normalization.htm ny/files/Normalization.htm Multivalued Dependencies (Ozmar Zaine): al/notes/Chapter7/node13.html al/notes/Chapter7/node13.html al/notes/Chapter7/node13.html