Functional Dependencies and Normalization

Slides:



Advertisements
Similar presentations
Chapter 5 Normalization of Database Tables
Advertisements

5 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Chapter 5 Normalization of Database Tables
Chapter 5 Normalization of Database Tables
 Definition  Components  Advantages  Limitations Contents  Definition Definition  Normal Forms Normal Forms  First Normal Form First Normal Form.
Boyce-Codd NF Takahiko Saito Spring 2005 CS 157A.
Need for Normalization
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Boyce-Codd Normal Form Kelvin Nishikawa SE157a-03 Fall 2006 Kelvin Nishikawa SE157a-03 Fall 2006.
1 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 5 Database Design: Normalization.
Normalization of Database Tables
4 Chapter 4 Normalization Hachim Haddouti. 4 Hachim Haddouti, CH4, see also Rob & Coronel 2 In this chapter, you will learn: What normalization is and.
1 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 5 Database Design 1: Normalization.
NORMALIZATION N. HARIKA (CSC).
Lecture 12 Inst: Haya Sammaneh
Component 4: Introduction to Information and Computer Science Unit 6: Databases and SQL Lecture 4 This material was developed by Oregon Health & Science.
NormalizationNormalization Chapter 4. Purpose of Normalization Normalization  A technique for producing a set of relations with desirable properties,
Concepts of Database Management, Fifth Edition
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
Database Design – Lecture 8
In this session, you will learn to: Describe data redundancy Describe the first, second, and third normal forms Describe the Boyce-Codd Normal Form Appreciate.
9/23/2012ISC329 Isabelle Bichindaritz1 Normalization.
Normalization.
Second Normal Form. A relation is said to be in 2NF if it is already in 1NF and it has no partial dependency. 2NF is based on the concept of fully functional.
11/10/2009GAK1 Normalization. 11/10/2009GAK2 Learning Objectives Definition of normalization and its purpose in database design Types of normal forms.
Normalisation 1NF to 3NF Ashima Wadhwa. In This Lecture Normalisation to 3NF Data redundancy Functional dependencies Normal forms First, Second, and Third.
Week 4 Lecture Part 1 of 3 Normalization of Database Tables Samuel ConnSamuel Conn, Asst. Professor.
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.
Normalization.
Chapter 5: Relational Database Design
Advanced Normalization
Normalization Karolina muszyńska
A brief summary of database normalization
Chapter 4: Relational Database Design
Chapter 5: Logical Database Design and the Relational Model
Normalization DBS201.
Payroll Management System
Advanced Normalization
Database Normalization
Normalization Refine data To attain a good DB design
A SIMPLE GUIDE TO FIVE NORMAL FORMS (See the next slide for required reading) Prof. Ghandeharizadeh 2018/11/14.
Normalization.
Normalization of Database Tables PRESENTED BY TANVEERA AKHTER FOR BCA 2ND YEAR dated:15/09/2015 DEPT. OF COMPUTER SCIENCE.
Normalization There is a sequence to normal forms:
Database Normalization
Chapter 6 Normalization of Database Tables
Module 5: Overview of Normalization
Normalization By Jason Park Fall 2005 CS157A.
Third Normal Form (3NF).
Database solutions The process of normalization Marzena Nowakowska Faculty of Management and Computer Modelling Kielce University of Technology rooms:
Normalization Dale-Marie Wilson, Ph.D..
Normalization Normalization
Normalization.
Normalization of Database Tables Uploaded by: mysoftbooks.ml
Normalization Normalization theory is based on the observation that relations with certain properties are more effective in inserting, updating and deleting.
4 Normal Form.
Normalization February 28, 2019 DB:Normalization.
Sampath Jayarathna Cal Poly Pomona
Sampath Jayarathna Cal Poly Pomona
Schema Refinement and Normal Forms
Lecture 5: Functional dependencies and normalization
Relational Database Design
Database Normalization.
Chapter 4 The Relational Model and Normalization
Normalization By Jason Park Fall 2005 CS157A.
Normalization DBS201.
Chapter 7a: Overview of Database Design -- Normalization
Database Normalization
Presentation transcript:

Functional Dependencies and Normalization

Normalization Normalization is a formalized procedure to eliminating redundancy from data by the progressive use of ‘non-lose decomposition’, which involves splitting records without losing information. In reducing the data model to the state where each bit of information is only held in one place, the update process is much simpler, more efficient and inconsistencies in the database are impossible. ภายหลังการแยกข้อมูลแล้วไม่มีการ loss information

Normalization (cont.) 5NF 4NF 3NF 2NF 1NF Redundancy Redundancy

Normalization (cont.) Normalization is based on the idea that an attribute may depend on another attribute in some way. There are 2 different kinds of dependencies involved up to 5 NF Functional dependency Multivalued dependence

Functional Dependence S# CITY P# QTY S1 Khon Kaen P1 100 P2 S2 Saraburii 200 S3 300 S4 Bangkok 400 P4 P5 การขึ้นต่อกันในเชิงของฟังก์ชัน QTY จะขึ้นกับ S# P# S# P# เป็นตัวกำหนด QTY S#,P# QTY QTY is functionally dependent on S#andP# S# and P# are the determinant of QTY

Functional Dependence In a relation including attribute A and B, B is functional dependent on A if, for every valid occurrence, the value A determines the value B An occurrence can not be used to show that a dependency is true, only that it is false A and B can be composite If B is ‘Functional Dependent on’ A, then A ‘is the determinant of B’ All fields are functionally dependent on the primary key – or indeed any candidate key – be definition.

First Normal Form A relation is in First Normal form if, and only if, it contains no multi-value or no repeating groups.

First NF (cont.) NO Name Province PayDate1 Amount1 PayDate2 Amount2 Somchai Khon Kaen 15/04/2004 5,000.00 30/04/2004 E002 Sompong Sarakham 4,500.00 E003 Somchay Ubon 5,200.00 Repeat

Problem Multi-value Staff ENO Name Dno DeptName ProjNo ProjName E001 Somchai D01 Physic P01, P02 NMR, Laser E002 Sompong P03 Medical Image processing E003 Somchay D02 Computer Science P04, P05 Voice ordering, Speech Coding E004 SomSiri P04, P06 Voice ordering, Speech Synthesis Problem Difficult to manipulate data Redundancy UPDATE ANOMALIES

Insert P06 Speech Corpus Staff ENO Name Dno DeptName ProjNo ProjName Somchai D01 Physic P01, P02 NMR, Laser E002 Sompong P03 Medical Image processing E003 Somchay D02 Computer Science P04, P05 Voice ordering, Speech Coding E004 SomSiri P04, P06 Voice ordering, Speech Synthesis We can not insert new project if the project has not assigned to any employee yet.

UPDATE ANOMALIES Staff ENO Name Dno DeptName ProjNo ProjName E001 Somchai D01 Physic P01, P02 NMR, Laser E002 Sompong P03 Medical Image processing E003 Somchay D02 Computer Science P04, P05 Voice ordering, Speech Coding E004 SomSiri P04, P06 Voice ordering, Speech Synthesis Change ProjName from Voice Ordering to Speech Ordering need to change all in Database

DELETE Problem Staff ENO Name Dno DeptName ProjNo ProjName E001 Somchai D01 Physic P01, P02 NMR, Laser E002 Sompong P03 Medical Image processing E003 Somchay D02 Computer Science P04, P05 Voice ordering, Speech Coding E004 SomSiri P04, P06 Voice ordering, Speech Synthesis Delete Employee E003 Somchay Project P03 Medical Image Processing was deleted also

Solution Remove the repeating group In case of multi-valued Create new relation Columns = Key + multi-valued Take its determinant with it

Repeating group Employee ENO Name Province PayDate1 Amount1 PayDate2 Somchai Khon Kaen 15/04/2004 5,000.00 30/04/2004 E002 Sompong Sarakham 4,500.00 E003 Somchay Ubon 5,200.00 Employee PayCheck ENO PayDate Amount E001 15/04/2004 5,000.00 30/04/2004 E002 4,500.00 E003 5,200.00 ENO Name Province E001 Somchai Khon Kaen E002 Sompong Sarakham E003 Somchay Ubon

Multi-Valued Staff ENO Name Dno DeptName ProjNo ProjName E001 Somchai Physic P01, P02 NMR, Laser E002 Sompong P03 Medical Image processing E003 Somchay D02 Computer Science P04, P05 Voice ordering, Speech Coding E004 SomSiri P04, P06 Voice ordering, Speech Synthesis

Multi-Valued ENO Name Dno DeptName ProjNo ProjName P05 P04 P06 Somchai D01 Physic P01 NMR P02 Laser E002 Sompong P03 Medical Image processing E003 Somchay D02 Computer Science P05 Voice ordering P04 Speech Coding E004 SomSiri P06 Speech Synthesis Manipulate easy Update Deptname easy But insert still has problem Insert Project still has problem

Second Normal Form (2NF) A relation is in first normal form if and only if It is in 1NF Every non-key attribute is dependent on all parts of the primary key.

2NF ? Staff ENO Name Dno DeptName ProjNo ProjName P05 P04 P06 Somchai D01 Physic P01 NMR P02 Laser E002 Sompong P03 Medical Image processing E003 Somchay D02 Computer Science P05 Voice ordering P04 Speech Coding E004 SomSiri P06 Speech Synthesis KEY = ENO + ProjNo Manipulate easy Update Deptname easy But insert still has problem Answer is No. Because ProjNo is dependent on ProjNo. (not all part of Key)

Problem ENO Name Dno DeptName ProjNo ProjName P05 P04 P06 Somchai D01 Physic P01 NMR P02 Laser E002 Sompong P03 Medical Image processing E003 Somchay D02 Computer Science P05 Voice ordering P04 Speech Coding E004 SomSiri P06 Speech Synthesis Manipulate easy Update Deptname easy But insert still has problem We can not insert Project if have not yet assigned project to any employee

Solution Remove the attribute involved Take its determinant with it

Normalize ENO Name Dno DeptName ProjNo ProjName P05 P04 P06 E001 Somchai D01 Physic P01 NMR P02 Laser E002 Sompong P03 Medical Image processing E003 Somchay D02 Computer Science P05 Voice ordering P04 Speech Coding E004 SomSiri P06 Speech Synthesis Manipulate easy Update Deptname easy But insert still has problem

Result PERSON(ENO,NAME,Dno,DeptName) PROJECT(ProjNo,ProjName) PERSON_Proj PERSON ProjNo ProjName P01 NMR P02 Laser P03 Medical Image processing P04 Speech Coding P05 Voice ordering P06 Speech Synthesis ENO ProjNo E001 P01 P02 E002 P03 E003 P04 E004 P05 P06 ENO Name Dno DeptName E001 Somchai D01 Physic E003 Somchay D02 Computer Science E004 SomSiri Manipulate easy Update Deptname easy But insert still has problem PERSON(ENO,NAME,Dno,DeptName) PROJECT(ProjNo,ProjName) PERSON_PROJ(ENO,ProjNo)

Third Normal Form A relation is in 3NF if, and only if: It is in 2NF Every non-key attribute is functionally dependent upon the key. (No non-key attribute is functional dependent on another non-key attribute) Or non-key attribute no transitive dependent on key

Transitive dependent R(A,B,C,D) ; A is Key, others are non- key If A → B and B → C can say A → B → C (C transitive dependent on A)

Because DeptName is dependent on Dno (has transitive dependent on key) 3NF? Project PERSON_Proj PERSON ProjNo ProjName P01 NMR P02 Laser P03 Medical Image processing P04 Speech Coding P05 Voice ordering P06 Speech Synthesis ENO ProjNo E001 P01 P02 E002 P03 E003 P04 E004 P05 P06 ENO Name Dno DeptName E001 Somchai D01 Physic E003 Somchay D02 Computer Science E004 SomSiri Manipulate easy Update Deptname easy But insert still has problem Answer is No Because DeptName is dependent on Dno (has transitive dependent on key)

Solution Remove the offending attributes Take the determinant along

Result PERSON ENO Name Dno Project ProjNo ProjName P04 P05 P06 ProjNo Somchai D01 E003 Somchay D02 E004 SomSiri Project PERSON_Proj ProjNo ProjName P01 NMR P02 Laser P03 Medical Image processing P04 Speech Coding P05 Voice ordering P06 Speech Synthesis ENO ProjNo E001 P01 P02 E002 P03 E003 P04 E004 P05 P06 Department Manipulate easy Update Deptname easy But insert still has problem Dno DeptName D01 Physic D02 Computer Science

Note The third normal form is often reached in practice by inspection, in a single step. Its meaning seems intuitively clear; it represents a formalization of designer’s common sense. This level of normalization is widely accepted as the initial target for a design which eliminates redundancy. However, there are higher normal forms which, although less frequently invoked, highlight further redundancy problems which may affect the designer

Boyce-Codd Normal Form (BCNF) A relation is in BCNF if, and only if, every determinant is a candidate key. BCNF is a refinement to third normal form, and tightens its duration.

Multivalued Dependence In a relation including attribute A, B and C, B is multivalued dependent on A if the set of B values matching a given A+C value pair, depends only on the A value.