Normalization.

Slides:



Advertisements
Similar presentations
Functional Dependencies and Normalization for Relational Databases
Advertisements

primary key constraint foreign key constraint
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
+ Review: Normalization and data anomalies CSCI 2141 W2013 Slide set modified from courses.ischool.berkeley.edu/i257/f06/.../Lecture06_257.ppt.
Functional Dependencies and Normalization for Relational Databases.
Functional Dependencies and Normalization for Relational Databases
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
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 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.
King Saud University College of Computer & Information Sciences Computer Science Department CS 380 Introduction to Database Systems Functional Dependencies.
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.
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.
Chapter Functional Dependencies and Normalization for Relational Databases.
Ihr Logo Fundamentals of Database Systems Fourth Edition El Masri & Navathe Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Ihr Logo Fundamentals of Database Systems Fourth Edition El Masri & Navathe Chapter 10 Functional Dependencies and Normalization for Relational Databases.
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
1 Functional Dependencies and Normalization Chapter 15.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Slide
Copyright © 2007 Ramez Elmasri and Shamkant B. Navathe Slide
Lecture 8: Database Concepts May 4, Outline From last lecture: creating views Normalization.
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
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.
Normalisation 1NF to 3NF Ashima Wadhwa. In This Lecture Normalisation to 3NF Data redundancy Functional dependencies Normal forms First, Second, and Third.
Deanship of Distance Learning Avicenna Center for E-Learning 1 Session - 7 Sequence - 1 Normalization DB Design Guidelines Presented by: Dr. Samir Tartir.
Al-Imam University Girls Education Center Collage of Computer Science 1 st Semester, 1432/1433H Chapter 10_part 1 Functional Dependencies and Normalization.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
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
10/3/2017.
10/3/2017.
COP 6726: New Directions in Database Systems
Normalization Database Management Systems, 3rd ed., Ramakrishnan and Gehrke, Chapter 19.
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
Normal forms First Normal Form (1NF) Second Normal Form (2NF)
Functional Dependencies and Normalization for Relational Databases
Database Management systems Subject Code: 10CS54 Prepared By:
Database Normalization
Normalization Murali Mani.
Functional Dependencies and Normalization
Outline: Normalization
Normalization DB Design Guidelines Presented by: Dr. Samir Tartir
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Normalization Normalization theory is based on the observation that relations with certain properties are more effective in inserting, updating and deleting.
Instructor: Mohamed Eltabakh
Normalization February 28, 2019 DB:Normalization.
Database Normalisation
Sampath Jayarathna Cal Poly Pomona
Relational Database Design
Chapter Outline 1 Informal Design Guidelines for Relational Databases
Presentation transcript:

Normalization

Normalization Database normalization is the process of removing redundant data from the database to improve storage efficiency, data integrity, and scalability. In the relational model, methods exist for quantifying how efficient a database is. These classifications are called normal forms (or NF), and there are algorithms for converting a given database between them. Normalization generally involves splitting existing tables into multiple ones, which must be re-joined or linked each time a query is issued.

Why Normalization? (Drawbacks of Redundant Information) Wastage of Storage Causes problems with update anomalies Insertion anomalies Deletion anomalies Modification anomalies

Benefits of Normalization Less storage space Quicker updates Less data inconsistency Clearer data relationships Easier to add data Flexible Structure

Example

New relat ion

EXAMPLE OF AN UPDATE ANOMALY Consider the relation: EMP_PROJ(Emp#, Proj#, Ename, Pname, No_hours) Changing the name of project number P1 from “Billing” to “Customer Accounting” may cause this update to be made for all employees working on project P1. EXAMPLE OF AN INSERT ANOMALY Cannot insert a project unless an employee is assigned to it. Conversely cannot insert an employee unless an he/she is assigned to a project. EXAMPLE OF AN DELETE ANOMALY When a project is deleted, it will result in deleting all the employees who work on that project. Alternately, if an employee is the sole employee on a project, deleting that employee would result in deleting the corresponding project.

Guidelines Each tuple in a relation should represent one entity or relationship instance. Design a schema that does not suffer from the insertion, deletion and update anomalies. If there are any anomalies present, then note them so that applications can be made to take them into account. Relations should be designed such that their tuples will have as few NULL values as possible Attributes that are NULL frequently could be placed in separate relations

Types of Normalization First Normal Form Second Normal Form Third Normal Form Boyce Codd Normal Form Fourth Normal Form (Multi Valued Dependencies) Fifth Normal Form (Join Dependencies)

Functional Dependencies An attribute Y is said to have a functional dependency on a set of attributes X (written X →Y) if and only if each X value is associated with precisely one Y value. Functional Dependencies-Example

Functional Dependencies-Example {Ssn,Pnumber} -> {Hours} {Ssn} -> {Ename } {Pnumber} -> {Pname, Plocation}

Types of Functional Dependencies Trivial functional dependency A trivial functional dependency is a functional dependency of an attribute on a superset of itself. {Ssn,Pnumber} -> {Hours} Trivial {Ssn} -> {Ename } Non trivial Full functional dependency An attribute is fully functionally dependent on a set of attributes X if it is functionally dependent on X, and not functionally dependent on any proper subset of X. {Ssn,Pnumber} -> {Hours} Transitive dependency A transitive dependency is an indirect functional dependency, one in which X→Z only by virtue of X→Y and Y→Z. Multivalued dependency A multivaluesd dependency is a constraint according to which the presence of certain rows in a table implies the presence of certain other rows. Join dependency A table T is subject to a join dependency if T can always be recreated by joining multiple tables each having a subset of the attributes of T.

Inference Rules for FDs (Reflexive) If Y subset-of X, then X -> Y (Augmentation) If X -> Y, then XZ -> YZ (Transitive) If X -> Y and Y -> Z, then X -> Z Decomposition: If X -> YZ, then X -> Y and X -> Z Union: If X -> Y and X -> Z, then X -> YZ Pseudo transitivity: If X -> Y and WY -> Z, then WX -> Z

First Normal Form (1NF) A relation is said to be in First Normal Form (1NF) if and only if each attribute of the relation is atomic. It does not allows the composite and multi valued attributes. First Normal Form (1NF) sets the very basic rules for an organized database: Eliminate duplicative columns from the same table. Create separate tables for each group of related data and identify each row with a unique column (the primary key).

First Normal Form (1NF)-Example Apply First Normal Form ->

First Normal Form (1NF)-Example Decompose the relation into {Ename, Ssn, Bdate, Address, Dnumber} {Dnumber, Dname, Dmgr_Ssn}

First Normal Form (1NF)-Result

Second Normal Form (2NF) A relation schema R is in second normal form (2NF) if a relation in 1NF and every non key attribute A in R is fully functionally dependent on the primary key

Second Normal Form (2NF)-Example

FD in 2NF

FD in 2NF

Results

Third Normal Form A relation schema R is in third normal form (3NF) if a table is in second normal form (2NF) and there are no transitive dependencies. (OR) Meet all the requirements of the 1NF Meet all the requirements of the 2NF Remove columns that are not dependent upon the primary key.

Third Normal Form-Example FD ?

FD in 3NF

FD in 3NF

Results

Comparison of 1NF, 2NF & 3NF 1NF Remove repeating groups 2NF Remove partial key dependencies 3NF Remove transitive dependencies

BCNF (Boyce Codd Normal Form) A relation schema R is in BCNF if for every nontrivial FD X-> Y in R, X is a candidate key. (OR) A relation is in BCNF, if and only if, every determinant is a candidate key. Each normal form is strictly stronger than the previous one Every 2NF relation is in 1NF Every 3NF relation is in 2NF Every BCNF relation is in 3NF There exist relations that are in 3NF but not in BCNF The goal is to have each relation in BCNF (or 3NF)

3NF VS BCNF 3NF BCNF A relation schema R is in 3NF if for every nontrivial FD X-> Y in R, X is not a candidate key A relation schema R is in Boyce- Codd Normal Form (BCNF) if for every nontrivial FD X-> Y in R, X is a candidate key 3NF has some redundancy BCNF removes all redundancies caused by FD’s Performance is Lesser than BCNF Better Performance than 3NF

Example- 1NF,2NF,3NF & BCNF FD ?

Example- 1NF,2NF,3NF & BCNF FD ? Patno -> PatName Patno,appNo -> Time,doctor

Apply Normalization Apply 1NF Eliminating Repeating Groups Apply 2NF 2NF Eliminate partial key dependencies R1(Patno,appNo,time,doctor) R2(Patno,PatName)  Apply 3NF 3NF Eliminate transitive dependencies None: so just as 2NF Apply BCNF Every determinant is a candidate key It is in BCNF Form.