NORMALIZATION. Normalization Normalization: The process of decomposing unsatisfactory "bad" relations by breaking up their attributes into smaller relations.

Slides:



Advertisements
Similar presentations
Functional Dependencies and Normalization for Relational Databases
Advertisements

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 =
Ch 10, Functional Dependencies and Normal forms
Functional Dependencies and Normalization for Relational Databases.
Kingdom of Saudi Arabia Ministry of Higher Education Al-Imam Muhammad Ibn Saud Islamic University College of Computer and Information Sciences Normalization.
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
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.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Chapter 8 Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
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.
IS 230Lecture 8Slide 1 Normalization Lecture 9. IS 230Lecture 8Slide 2 Lecture 8: Normalization 1. Normalization 2. Data redundancy and anomalies 3. Spurious.
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.
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.
Functional Dependencies and Normalization for Relational Databases.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
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.
Copyright © 2004 Pearson Education, Inc. Functional Dependencies & DB Normalization The main reference of this presentation is the textbook and PPT from.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Lecture 8: Database Concepts May 4, Outline From last lecture: creating views Normalization.
Lecture9:Functional Dependencies and Normalization for Relational Databases Ref. Chapter Lecture9 1.
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
Dr. Mohamed Osman Hegaz1 Logical data base design (2) Normalization.
What is normalization ? Proposed by Codd in 1972 Takes a relation through a series of steps to certify whether it satisfies a certain normal form Initially.
Normalization. 2 u Main objective in developing a logical data model for relational database systems is to create an accurate representation of the data,
Database Design FUNCTIONAL DEPENDENCES NORMAL FORMS D. Christozov / G.Tuparov INF 280 Database Systems: DB design: Normal Forms 1.
Lecture 10 Normalization. Introduction Relations derived from ER model may be ‘faulty’ – Subjective process. – May cause data redundancy, and insert/delete/update.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
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.
Copyright © 2016 Ramez Elmasri and Shamkant B. Navathe.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Chapter 14 Functional Dependencies and Normalization Informal Design Guidelines for Relational Databases –Semantics of the Relation Attributes –Redundant.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Functional Dependencies and Normalization for Relational Databases تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في ذلك. حيث المرجع.
10/3/2017.
10/3/2017.
COP 6726: New Directions in Database Systems
Functional Dependency and Normalization
CHAPTER 14 Basics of Functional Dependencies and Normalization for Relational Databases.
Functional Dependencies and Normalization for Relational Databases
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Functional Dependencies and Normalization for RDBs
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Database Management systems Subject Code: 10CS54 Prepared By:
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
3.1 Normalization of Relations (1)
Presentation transcript:

NORMALIZATION

Normalization Normalization: The process of decomposing unsatisfactory "bad" relations by breaking up their attributes into smaller relations to: 1. Minimizing Redundancy 2. Minimizing the Insertion, Deletion, And Update Anomalies Normal form: Condition using keys and FDs of a relation to certify whether a relation schema is in a particular normal form

Steps of Normalisation Select the data source and convert into an unnormalised table (UNF) Transform the unnormalised data into first normal form 1NF 2NF3NF Occasionally, the data may still be subject to anomalies in third normal form. In this case, we may have to perform further transformations. BCNF4NF 5NF

Keys  A superkey of a relation schema R = {A 1, A 2,...., A n } is a set of attributes S subset- of R with the property that no two tuples t 1 and t 2 in any legal relation state r of R will have t 1 [S] = t 2 [S]  A key K is a superkey with the additional property that removal of any attribute from K will cause K not to be a superkey any more.  A key is a minimal superkey  If a relation schema has more than one key, each is called a candidate key.  One of the candidate keys is arbitrarily designated to be the primary key, and the others are called secondary keys.

Prime and Non Prime Attributes  Prime attribute An attribute which is a member of some candidate key  Nonprime attribute Not a member of any candidate key.

First Normal Form(1NF) RULE: First normal form (INF) states that the domain of an attribute must include only atomic (simple, indivisible) values.  Disallows  Composite attributes  Multivalued attributes  Nested relations; attributes whose values for an individual tuple are non-atomic

Example : Suppose that we extend DEPARTMENT by including the DLOCATIONS attribute as shown in the fig. FIRST NORMAL FORM – 1NF Is Department is 1 NF???

Three techiques Technique 1: a.Remove the attribute DLOCATIONS that violates 1NF b.Place the removed attribute in a separate relation DEPT_LOCATIONS along with the primary key (DNUMBER) of DEPARTMENT. c.The primary key of this new relation is the combination {DNUMBER, DLOCATION} Techniques to acheive1NF

Technique 2: Expand the key so that there will be a separate tuple in the original DEPARTMENT relation for each location of a DEPARTMENT. In this case, the primary key becomes the combination {DNUMBER, DLOCATION}. Techniques to acheive1NF Disadvantage: Redundancy

Technique 3: If a maximum number of values is known for the attribute-for example, if it is known that at most three locations can exist for a department-replace the DLOCATIONS attribute by three atomic attributes: DLOCATION1, DLOCATION2, and DLOCATION3. Disadvantage 1.Introducing null values if most departments have fewer than three locations. 2.Introducing spurious tuples Techniques to acheive1NF

Of the three solutions above, the first is generally considered best because it does not suffer from redundancy and it is completely general having no limit placed on a maximum number of values.

Example: Consider following NESTED RELATION (each tuple can have a relation within it) EMP_PROJ (SSN, ENAME, {PROJS(PNUMBER, HOURS)}) 1NF DISALLOW MULTIVALUED Nested Relations

1.Remove the nested relation attributes into a new relation and propagate the primary key into it. 2.The primary key of the new relation will contain the partial key along with the primary key of the original relation. To normalize this into INF :

1.Definition: Full functional dependency A functional dependency X  Y is a full functional dependency if removal of any attribute A from X means that the dependency does not hold any more; i.e. for any attribute A ϵ X, (X - {A}) v does not functionally determine Y 2.Definition: Partial functional dependency A functional dependency X  Y is a partial dependency if some attribute A can be removed from X and the dependency still holds; i.e. for some A ϵ X, (X - {A})  Y. SECOND NORMAL FORM – 2NF (BASED ON FDs)

{SSN, PNUMBER}  HOURS is a full dependency {SSN, PNUMBER}  ENAME is partial because SSN  ENAME holds. Definition. A relation schema R is in 2NF if every nonprime attribute A in R is fully functionally dependent on the primary key of R. The test for 2NF involves testing for functional dependencies whose left-hand side attributes are part of the primary key. If the primary key contains a single attribute, the test need not be applied at all. SECOND NORMAL FORM :

The EMP_PROJ relation is in 1NF but not in 2NF. Because of FD2 & FD3. Few non-prime attributes are partially dependent on primary key. i.e. a part of primary key can fully determine that non-prime attribute. SECOND NORMAL FORM – 2NF (Definition) WHY?

Technique: Division of given schema into smaller schemas, which would contain nonprime attributes and the associated part of the primary key on which they were functionally dependent. FD1, FD2, and FD3 lead to the decomposition of EMP_PRO] into the three relation schemas EP1 EP2, and EP3 HOW TO ACHIEVE 2NF ?

TRANSITIVE DEPENDENCY A functional dependency X  Y in a relation schema R is a transitive dependency if there is a set of attributes Z that is neither a candidate key nor a subset of any key of R, and both X  Z and Z  Y hold. THIRD NORMAL FORM – 3NF (BASED ON TRANSITIVE DEPENDENCY) SSN  DMGRSSN is transitive through DNUMBER in EMP_DEPT. Because both the dependencies SSN  DNUMBER and DNUMBER  DMGRSSN hold and DNUMBER is neither a key itself nor a subset of any key of EMP_DEPT Example

A relation schema R is in 3NF if it satisfies 2NF and no nonprime attribute of R is transitively dependent on the primary key. The relation schema EMP_DEPT is in 2NF, since no partial dependencies on a key exist. However, EMP_DEPT is not in 3NF because 1.SSN  DNUMBER, DNUMBER  DMGRSSN, hence SSN  DMGRSSN 2.SSN  DNUMBER, DNUMBER  DNAME, hence SSN  DNAME THIRD NORMAL FORM – 3NF (DEFINITION) Previous Example

We can normalize EMP_DEPT by decomposing it into the two 3NF relation schemas ED1 and ED2 shown in the Figure A NATURAL JOIN operation on ED1 and ED2 will recover the original relation EMP_DEPT without generating spurious tuples. HOW TO ACHIEVE 3NF ?

SUMMARY

GENERAL DEFINITIONS OF SECOND AND THIRD NORMAL FORMS

The previous definitions of 2NF and 3NF did not considered other candidate keys of the relation, if any. NOTE 1: Notice that this does not affect the definition of 1NF, since it is independent of keys and functional dependencies NOTE 2: As a general definition of prime attribute, an attribute that is part of any candidate key will be considered as prime NEED FOR GENERALIZED DEFINITION

A relation schema R is in 2NF if every nonprime attribute A in R is not partially dependent on any key of R. OR A relation schema R is in 2NF if every nonprime attribute A in R is fully functionally dependent on every key of R. GENERAL DEFINITION OF SECOND NORMAL FORM EXAMPLE: Consider the relation schema LOTS which describes parcels of land for sale in various counties of a state. Suppose that there are two candidate keys: PROPERTY_ID# and {COUNTY_NAME, LOT#}; THIS IS NOT IN 2NF BECAUSE OF FD3

To normalize LOTS into 2NF, we decompose it into the two relations LOTS1 and LOTS2, shown in the following Figure HOW TO ACHIEVE 2NF ?

A relation schema R is in 3NF if, whenever a nontrivial functional dependency X  A holds in R; then either of below condition holds: (a) X is a superkey of R (b) A is a prime attribute of R. GENERAL DEFINITION OF THIRD NORMAL FORM Because of FD4 (AREA  PRICE) in LOTS1 violates 3NF. Reason: AREA is not a superkey and PRICE is not a prime attribute in LOTS1.

To normalize LOTS1 into 3NF, we decompose it into the relation schemas LOTS1A and LOTS1B shown in Figure HOW TO ACHIEVE 3NF ?