Normalization Dale-Marie Wilson, Ph.D..

Slides:



Advertisements
Similar presentations
© Pearson Education Limited, Chapter 8 Normalization Transparencies.
Advertisements

The Relational Model System Development Life Cycle Normalisation
1 Database Systems: A Practical Approach to Design, Implementation and Management International Computer Science S. Carolyn Begg, Thomas Connolly Lecture.
Normalization I.
Chapter 5 Normalization Transparencies © Pearson Education Limited 1995, 2005.
1 Minggu 10, Pertemuan 19 Normalization (cont.) Matakuliah: T0206-Sistem Basisdata Tahun: 2005 Versi: 1.0/0.0.
Introduction to Schema Refinement. Different problems may arise when converting a relation into standard form They are Data redundancy Update Anomalies.
Normalization. Introduction Badly structured tables, that contains redundant data, may suffer from Update anomalies : Insertions Deletions Modification.
FUNCTIONAL DEPENDENCIES
Lecture 12 Inst: Haya Sammaneh
Chapter 6 Normalization 正規化. 6-2 In This Chapter You Will Learn:  更動異常  How tables that contain redundant data can suffer from update anomalies ( 更動異常.
Normalization. 2 Objectives u Purpose of normalization. u Problems associated with redundant data. u Identification of various types of update anomalies.
NormalizationNormalization Chapter 4. Purpose of Normalization Normalization  A technique for producing a set of relations with desirable properties,
Chapter 13 Normalization Transparencies. 2 Last Class u Access Lab.
Normalization. Learners Support Publications 2 Objectives u The purpose of normalization. u The problems associated with redundant data.
1 Pertemuan 23 Normalisasi Matakuliah: >/ > Tahun: > Versi: >
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
Normalization Transparencies
CSC271 Database Systems Lecture # 28.
CSC271 Database Systems Lecture # 29. Summary: Previous Lecture  The normalization process  1NF, 2NF, 3NF  Inference rules for FDs  BCNF.
Chapter 13 Normalization Transparencies. 2 Chapter 13 - Objectives u Purpose of normalization. u Problems associated with redundant data. u Identification.
Chapter 13 Normalization. 2 Chapter 13 - Objectives u Purpose of normalization. u Problems associated with redundant data. u Identification of various.
Chapter 13 Normalization © Pearson Education Limited 1995, 2005.
Lecture 5 Normalization. Objectives The purpose of normalization. How normalization can be used when designing a relational database. The potential problems.
Chapter 13 Normalization Transparencies Last Updated: 08 th May 2011 By M. Arief
Chapter 10 Normalization Pearson Education © 2009.
Functional Dependency, Normalization
Normalization Transparencies 1. ©Pearson Education 2009 Objectives How the technique of normalization is used in database design. How tables that contain.
Chapter 13 Normalization Transparencies. 2 Chapter 13 - Objectives u How to undertake process of normalization. u How to identify most commonly used normal.
Lecture Nine: Normalization
Dr. Mohamed Osman Hegaz1 Logical data base design (2) Normalization.
© Pearson Education Limited, Normalization Bayu Adhi Tama, M.T.I. Faculty of Computer Science University of Sriwijaya.
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,
IST Database Normalization Todd Bacastow IST 210.
11/10/2009GAK1 Normalization. 11/10/2009GAK2 Learning Objectives Definition of normalization and its purpose in database design Types of normal forms.
Normalization. Overview Earliest  formalized database design technique and at one time was the starting point for logical database design. Today  is.
ITD1312 Database Principles Chapter 4C: Normalization.
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
NORMALIZATION.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
Chapter 9 Normalization Chapter 14 & 15 in Textbook.
Chapter 8 Relational Database Design Topic 1: Normalization Chuan Li 1 © Pearson Education Limited 1995, 2005.
Normalization.
Advanced Normalization
Normalization Karolina muszyńska
Normalization DBMS.
Normalization Dongsheng Lu Feb 21, 2003.
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
Advanced Normalization
Advanced Normalization
Normalization Lecture 7 May Aldoayan.
Chapter 14 Normalization
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Normalization.
Database Normalization
Chapter 14 & Chapter 15 Normalization Pearson Education © 2009.
Normalization.
Normalization and FD.
Normalization Dongsheng Lu Feb 21, 2003.
Chapter 7 Normalization Chapter 13 in Textbook.
Chapter 14 Normalization – Part I Pearson Education © 2009.
Normalization – Part II
Chapter 14 Normalization.
Minggu 9, Pertemuan 18 Normalization
Chapter 14 Normalization.
Normalization February 28, 2019 DB:Normalization.
國立臺北科技大學 課程:資料庫系統 2015 fall Chapter 14 Normalization.
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
Chapter 14 Normalization Pearson Education © 2009.
Presentation transcript:

Normalization Dale-Marie Wilson, Ph.D.

Purpose of Normalization Definition A technique for producing a set of suitable relations that support data requirements of an enterprise Characteristics of suitable set of relations: Minimal number of attributes necessary to support data requirements of enterprise Attributes with close logical relationship found in same relation Minimal redundancy with each attribute Represented only once Exception of attributes that form all or part of foreign keys

Purpose of Normalization Benefits of using database with suitable set of relations: Easier for user to access and maintain data Takes up minimal storage space on computer

How Normalization Supports Database Design

Data Redundancy and Update Anomalies Major aim of relational database design To group attributes into relations to minimize data redundancy Potential benefits: Updates to data stored achieved with minimal number of operations Reduces opportunities for data inconsistencies Reduces file storage space required by base relations thus minimizing costs

Data Redundancy and Update Anomalies

Data Redundancy and Update Anomalies Relations that contain redundant information may potentially suffer from update anomalies Types of update anomalies: Insertion Deletion Modification

Data Redundancy and Update Anomalies

Lossless-join and Dependency Preservation Properties Two important properties of decomposition: Lossless-join property Ability to find any instance of original relation from corresponding instances in smaller relations Dependency preservation property Ability to enforce constraint on original relation by enforcing some constraint on each of smaller relations

Functional Dependencies Determinant refers to attribute or group of attributes on left-hand side of arrow

Functional Dependency Example Consider the values shown in staffNo and sName attributes of the Staff relation Based on sample data, the following functional dependencies appear to hold staffNo → sName sName → staffNo

Functional Dependencies The only functional dependency that remains true for all possible values for staffNo and sName attributes of Staff relation is: staffNo → sName

Functional Dependencies Characteristics: Full functional dependency Determinants should have minimal number of attributes necessary to maintain functional dependency with the attribute(s) on the right hand-side If A and B are attributes of relation, B is fully functionally dependent on A, if B is functionally dependent on A, but not on any proper subset of A

Functional Dependency Example staffNo, sName → branchNo True - each value of (staffNo, sName) associated with single value of branchNo branchNo also functionally dependent on subset of (staffNo, sName), staffNo. Partial dependency

Functional Dependencies Characteristics: one-to-one relationship between attribute(s) on left-hand side (determinant) and right-hand side of functional dependency Holds for all time Determinant has minimal number of attributes necessary to maintain dependency with attribute(s) on right hand-side

Transitive Dependencies Existence of transitive dependency potentially cause update anomalies A condition where A, B, and C are attributes of a relation such that if A → B and B → C, then C is transitively dependent on A via B (provided that A is not functionally dependent on B or C

Transitive Dependency Example staffNo → sName, position, salary, branchNo, bAddress branchNo → bAddress Transitive dependency, branchNo → bAddress exists on staffNo via branchNo

Process of Normalization Formal technique for analyzing a relation based on its primary key and the functional dependencies between the attributes of that relation Executed as series of steps Each step corresponds to specific normal form with known properties

Identifying Functional Dependencies Meaning of each attribute and relationships between attributes must be well understood Provided by enterprise in form of discussions with users and/or documentation e.g. users’ requirements specification If users unavailable and/or documentation incomplete Database designer uses common sense and/or experience to provide missing information

Identifying Functional Dependencies Example

Identifying Functional Dependencies Example In StaffBranch relation, assume that position held and branch determine a member of staff’s salary Identify functional dependencies for StaffBranch relation as: staffNo → sName, position, salary, branchNo, bAddress branchNo → bAddress bAddress → branchNo branchNo, position → salary bAddress, position → salary

Using Sample Data to Identify FD Example

Using Sample Data to Identify FD Example Consider data for attributes denoted A, B, C, D, and E in Sample relation Important Must establish sample data values shown in relation are representative of all possible values that can be held by attributes A, B, C, D, and E

Identifying the Primary Key Main purpose of identifying set of functional dependencies for relation To specify the set of integrity constraints that must hold on relation Integrity constraint to consider first Identification of candidate keys Choice of primary key

Example - Identify Primary Key for StaffBranch Relation

Example - Identify Primary Key for StaffBranch Relation StaffBranch relation has five functional dependencies Determinants are staffNo, branchNo, bAddress, (branchNo, position), and (bAddress, position) To identify all candidate key(s) Identify attribute (or group of attributes) that uniquely identifies each tuple in relation

Example - Identify Primary Key for StaffBranch Relation All attributes not part of a candidate key should be functionally dependent on key For StaffBranch relation: One candidate key, staffNo => one primary key, staffNo

Example - Identify Primary Key for Sample Relation

Example - Identify Primary Key for Sample Relation Sample relation has four functional dependencies Determinants are A, B, C, and (A, B) One determinant functionally determines all other attributes of relation (A, B) (A, B) identified as primary key

Normalization Process As normalization proceeds Relations become progressively more restricted (stronger) in format Less vulnerable to update anomalies

Normalization Process

Normal Forms Unnormalized form (UNF) To create an unnormalized table Table that contains one or more repeating groups To create an unnormalized table Transform data from information source (e.g. form) into table format with columns and rows First Normal Form (1NF) A relation in which intersection of each row and column contains one and only one value

Normal Forms UNF to 1NF Nominate attribute or group of attributes to act as the key for unnormalized table Identify repeating group(s) in unnormalized table which repeats key attribute(s) Remove the repeating group by Entering appropriate data into empty columns of rows containing repeating data (‘flattening’ the table) Placing repeating data along with copy of original key attribute(s) into separate relation

Normal Forms Second Normal Form (2NF) A relation that is in 1NF and every non-primary-key attribute is fully functionally dependent on the primary key Based on concept of full functional dependency Full functional dependency indicates that if A and B are attributes of a relation B is fully dependent on A if B is functionally dependent on A but not on any proper subset of A

Normal Forms 1NF to 2NF Identify primary key for 1NF relation Identify functional dependencies If partial dependencies exist on primary key Remove by placing in new relation along with copy of determinant

Normal Forms Third Normal Form (3NF) A relation that is in 1NF and 2NF and in which no non-primary-key attribute is transitively dependent on the primary key Based on concept of transitive dependency Transitive Dependency is a condition where A, B and C are attributes of relation such that if A  B and B  C, then C is transitively dependent on A through B. (Provided that A is not functionally dependent on B or C)

Normal Forms 2NF to 3NF Identify primary key in 2NF relation Identify functional dependencies If transitive dependencies exist on primary key Remove by placing them in new relation along with a copy of dominant

Normal Forms Boyce-Codd Normal Form (BCNF) A relation is in BCNF if and only if every determinant is a candidate key Based on functional dependencies Takes into account all candidate keys in relation Adds constraints compared with 3NF

Normal Forms Every relation in BCNF is in 3NF Relation in 3NF not necessarily in BCNF Violation of BCNF rare Violations of BCNF occur when: Relation contains two (or more) composite candidate keys Candidate keys overlap i.e. have at least one attribute in common

Normalization Example

Normalization Example

Normalization Example

Normalization Example 2NF PropertyInspection(propertyNo, iDate, iTime, comments, staffNo, sName, carReg) Property(propertyNo, pAddress) 3NF PropertyInspection(propertyNo, iDate, iTime, comments, staffNo, sName, carReg) Staff(staffNo, sName)

Normalization Example BCNF Property Relation fd2 propertyNo → pAddress Staff Relation fd3 staffNo → sName PropertyInspect Relation fd1’ propertyNo, iDate → iTime, comments, staffNo, carReg fd4 staffNo, iDate → carReg fd5’ carReg, iDate, iTime → propertyNo, comments, staffNo fd6’ staffNo, iDate, iTime → propertyNo, comments

Normalization Example BCNF StaffCar(staffNo, iDate, carReg) Inspection(propertyNo, iDate, iTime, comments, staffNo) Property(propertyNo, pAddress) Staff(staffNo, sName) Loss of fd: carReg, iDate, iTime → propertyNo, paddress, comments, staffNo, sName If not, propertyInspect has data redundancy PropertyInspection(propertyNo, iDate, iTime, comments, staffNo, sName, carReg)

Normalization Example

Chapters covered: Chpts 13 & 14.1 – 14.3