CS263:Revision on Normalisation

Slides:



Advertisements
Similar presentations
Normalisation.
Advertisements

 Definition  Components  Advantages  Limitations Contents  Definition Definition  Normal Forms Normal Forms  First Normal Form First Normal Form.
Normalisation to 3NF Database Systems Lecture 11 Natasha Alechina.
PMIT-6102 Advanced Database Systems By- Jesmin Akhter Assistant Professor, IIT, Jahangirnagar University.
Normalization Dr. Mario Guimaraes. Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints.
Fundamentals, Design, and Implementation, 9/e Chapter 4 The Relational Model and Normalization.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Normalization I.
Normalization of Database Tables
Chapter 5 Normalization Transparencies © Pearson Education Limited 1995, 2005.
Project and Data Management Software
Normalization II. Boyce–Codd Normal Form (BCNF) Based on functional dependencies that take into account all candidate keys in a relation, however BCNF.
Chapter 3 The Relational Model and Normalization
Normalization. Introduction Badly structured tables, that contains redundant data, may suffer from Update anomalies : Insertions Deletions Modification.
Week 6 Lecture Normalization
DBSQL 4-1 Copyright © Genetic Computer School 2009 Chapter 4 Database Design.
Lecture 12 Inst: Haya Sammaneh
Modelling Techniques - Normalisation Description and exemplification of normalisation.Description and exemplification of normalisation. Creation of un-normalised.
Fundamentals, Design, and Implementation, 9/e. Database Processing: Fundamentals, Design and Implementation, 9/e by David M. KroenkeChapter 4/2 Copyright.
Avoiding Database 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,
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.
Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang.
SALINI SUDESH. Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of.
Normalization Transparencies
Schema Refinement and Normal Forms 20131CS3754 Class Notes #7, John Shieh.
Chapter 7 1 Database Principles Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that.
Switch off your Mobiles Phones or Change Profile to Silent Mode.
Module Coordinator Tan Szu Tak School of Information and Communication Technology, Politeknik Brunei Semester
CSC271 Database Systems Lecture # 28.
IMS 4212: Normalization 1 Dr. Lawrence West, Management Dept., University of Central Florida Normalization—Topics Functional Dependency.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
Chapter 13 Normalization Transparencies. 2 Chapter 13 - Objectives u Purpose of normalization. u Problems associated with redundant data. u Identification.
1 5 Normalization. 2 5 Database Design Give some body of data to be represented in a database, how do we decide on a suitable logical structure for that.
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.
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
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.
ITN Table Normalization1 ITN 170 MySQL Database Programming Lecture 3 :Database Analysis and Design (III) Normalization.
Normalization Transparencies 1. ©Pearson Education 2009 Objectives How the technique of normalization is used in database design. How tables that contain.
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.
Lecture No 13 Functional Dependencies & Normalization ( II ) Mar 3 rd 2011 Database Systems.
Database Processing: Fundamentals, Design and Implementation, 9/e by David M. KroenkeChapter 4/1 Copyright © 2004 Please……. No Food Or Drink in the class.
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,
PMIT-6102 Advanced Database Systems By- Jesmin Akhter Assistant Professor, IIT, Jahangirnagar University.
Switch off your Mobiles Phones or Change Profile to Silent Mode.
PMIT-6102 Advanced Database Systems
Lecture 3 Functional Dependency and Normal Forms Prof. Sin-Min Lee Department of Computer Science.
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.
RELATIONAL TABLE NORMALIZATION. Key Concepts Guidelines for Primary Keys Deletion anomaly Update anomaly Insertion anomaly Functional dependency Transitive.
PMIT-6102 Advanced Database Systems By- Jesmin Akhter Assistant Professor, IIT, Jahangirnagar University.
NormalisationNormalisation Normalization is the technique of organizing data elements into records. Normalization is the technique of organizing data elements.
IMS 4212: Normalization 1 Dr. Lawrence West, Management Dept., University of Central Florida Normalization—Topics Functional Dependency.
ITD1312 Database Principles Chapter 4C: Normalization.
IT-501 Database Management Systems By- Jesmin Akhter Assistant Professor, IIT, Jahangirnagar University.
Logical Database Design and Relational Data Model Muhammad Nasir
Normalisation Worked example for an Order Remember : The data should depend upon the key, the whole key and nothing but the key.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
Chapter 8 Relational Database Design Topic 1: Normalization Chuan Li 1 © Pearson Education Limited 1995, 2005.
Normalization.
Database Normalization
Chapter 4.1 V3.0 Napier University Dr Gordon Russell
Normalization Dale-Marie Wilson, Ph.D..
Normalisation to 3NF.
Normalisation 1 Unit 3.1 Dr Gordon Russell, Napier University
Presentation transcript:

CS263:Revision on Normalisation

LECTURE PLAN Purpose of Normalisation Redundancy and Data Anomalies Repeating Groups Functional Dependency Transitive Dependency Stages of Normalisation

Purpose of Normalisation To avoid redundancy by storing each ‘fact’ within the database only once. To put data into a form that conforms to relational principles (e.g., single valued attributes, each relation represents one entity) - no repeating groups. To put the data into a form that is more able to accurately accommodate change. To avoid certain updating ‘anomalies’. To facilitate the enforcement of data constraints.

Redundancy and Data Anomalies Redundant data is where we have stored the same ‘information’ more than once. i.e., the redundant data could be removed without the loss of information. Example: We have the following relation that contains staff and department details: staffNo job dept dname city SL10 Salesman 10 Sales Stratford SA51 Manager 20 Accounts Barking DS40 Clerk 20 Accounts Barking OS45 Clerk 30 Operations Barking Insert Anomaly: We can’t insert a dept without inserting a member of staff that works in that department Update Anomaly: We could change the name of the dept that SA51 works in without simultaneously changing the dept that DS40 works in. Deletion Anomaly: By removing employee SL10 we have removed all information pertaining to the Sales dept. Such ‘redundancy’ could lead to the following ‘anomalies’

Repeating Groups A repeating group is an attribute (or set of attributes) that can have more than one value for a primary key value. Example: We have the following relation that contains staff and department details and a list of telephone contact numbers for each member of staff. staffNo job dept dname city contact number SL10 Salesman 10 Sales Stratford 018111777, 018111888, 079311122 SA51 Manager 20 Accounts Barking 017111777 DS40 Clerk 20 Accounts Barking OS45 Clerk 30 Operations Barking 079311555 Repeating Groups are not allowed in a relational design, since all attributes have to be ‘atomic’ - i.e., there can only be one value per cell in a table!

Functional Dependency Formal Definition: Attribute B is functionally dependant upon attribute A (or a collection of attributes) if a value of A determines a single value of attribute B at any one time. Formal Notation: A  B This should be read as ‘A determines B’ or ‘B is functionally dependant on A’. A is called the determinant and B is called the object of the determinant. staffNo job dept dname SL10 Salesman 10 Sales SA51 Manager 20 Accounts DS40 Clerk 20 Accounts OS45 Clerk 30 Operations Example: staffNo  job staffNo  dept staffNo  dname dept  dname Functional Dependencies

Functional Dependency Compound Determinants: If more than one attribute is necessary to determine another attribute in an entity, then such a determinant is termed a composite determinant. Full Functional Dependency: Only of relevance with composite determinants. This is the situation when it is necessary to use all the attributes of the composite determinant to identify its object uniquely. order# line# qty price A001 001 10 200 A002 001 20 400 A002 002 20 800 A004 001 15 300 Example: (Order#, line#)  qty (Order#, line#)  price Full Functional Dependencies

Functional Dependency Partial Functional Dependency: This is the situation that exists if it is necessary to only use a subset of the attributes of the composite determinant to identify its object uniquely. student# unit# room grade 9900100 A01 TH224 2 9900010 A01 TH224 14 9901011 A02 JS075 3 9900001 A01 TH224 16 Example: (student#, unit#)  grade Full Functional Dependencies unit#  room Partial Functional Dependencies Repetition of data!

Transitive Dependency Definition: A transitive dependency exists when there is an intermediate functional dependency. Formal Notation: If A  B and B  C, then it can be stated that the following transitive dependency exists: A  B  C staffNo job dept dname SL10 Salesman 10 Sales SA51 Manager 20 Accounts DS40 Clerk 20 Accounts OS45 Clerk 30 Operations Example: staffNo  dept dept  dname staffNo  dept  dname Transitive Dependencies Repetition of data!

Normalisation - Relational Model In order to comply with the relational model it is necessary to 1) remove repeating groups and 2) avoid redundancy and data anomalies by remoting partial and transitive functional dependencies. Relational Database Design: All attributes in a table must be atomic, and solely dependant upon the fully primary key of that table. NORMALISATION ACHIEVES THIS! THE KEY, THE WHOLE KEY, AND NOTHING BUT THE KEY!

Stages of Normalisation Unnormalised (UDF) First normal form (1NF) Remove repeating groups Second normal form (2NF) Remove partial dependencies Third normal form (3NF) Remove transitive dependencies Boyce-Codd normal form (BCNF) Remove remaining functional dependency anomalies Fourth normal form (4NF) Remove multivalued dependencies Fifth normal form (5NF) Remove remaining anomalies

Unnormalised Normal Form (UNF) Definition: A relation is unnormalised when it has not had any normalisation rules applied to it, and it suffers from various anomalies. This only tends to occur where the relation has been designed using a ‘bottom-up approach’. i.e., the capturing of attributes to a ‘Universal Relation’ from a screen layout, manual report, manual document, etc...

Unnormalised Normal Form (UNF) ORDER (order-no, order-date, cust-no, cust-name, cust-add, (prod-no, prod-desc, unit-price, ord-qty, line-total)*, order-total

First Normal Form (1NF) Remove repeating groups into a new relation Definition: A relation is in 1NF if, and only if, all its underlying attributes contain atomic values only. Remove repeating groups into a new relation A repeating group is shown by a pair of brackets within the relational schema. ORDER (order-no, order-date, cust-no, cust-name, cust-add, (prod-no, prod-desc, unit-price, ord-qty, line-total)*, order-total Steps from UNF to 1NF: Remove the outermost repeating group (and any nested repeated groups it may contain) and create a new relation to contain it. Add to this relation a copy of the PK of the relation immediately enclosing it. Name the new entity (appending the number 1 to indicate 1NF) Determine the PK of the new entity Repeat steps until no more repeating groups.

Example - UNF to 1NF ORDER (order-no, order-date, cust-no, cust-name, cust-add, (prod-no, prod-desc, unit-price, ord-qty, line-total)*, order-total 1. Remove the outermost repeating group (and any nested repeated groups it may contain) and create a new relation to contain it. (rename original to indicate 1NF) ORDER-1 (order-no, order-date, cust-no, cust-name, cust-add, order-total (prod-no, prod-desc, unit-price, ord-qty, line-total) 2. Add to this relation a copy of the PK of the relation immediately enclosing it. ORDER-1 (order-no, order-date, cust-no, cust-name, cust-add, order-total (order-no, prod-no, prod-desc, unit-price, ord-qty, line-total) 3. Name the new entity (appending the number 1 to indicate 1NF) ORDER-LINE-1 (order-no, prod-no, prod-desc, unit-price, ord-qty, line-total) 4. Determine the PK of the new entity ORDER-LINE-1 (order-no, prod-no, prod-desc, unit-price, ord-qty, line-total)

Second Normal Form (2NF) Definition: A relation is in 2NF if, and only if, it is in 1NF and every non-key attribute is fully dependent on the primary key. Remove partial functional dependencies into a new relation Steps from 1NF to 2NF: Remove the offending attributes that are only partially functionally dependent on the composite key, and place them in a new relation. Add to this relation a copy of the attribute(s) which are the determinants of these offending attributes. These will automatically become the primary key of this new relation. Name the new entity (appending the number 2 to indicate 2NF) Rename the original entity (ending with a 2 to indicate 2NF)

Example - 1NF to 2NF ORDER-LINE-1 (order-no, prod-no, prod-desc, unit-price, ord-qty, line-total) 1. Remove the offending attributes that are only partially functionally dependent on the composite key, and place them in a new relation. ORDER-LINE-1 (order-no, prod-no, ord-qty, line-total) (prod-desc, unit-price) 2. Add to this relation a copy of the attribute(s) which determines these offending attributes. These will automatically become the primary key of this new relation.. (prod-no, prod-desc, unit-price) ORDER-LINE-1 (order-no, prod-no, ord-qty, line-total) 3. Name the new entity (appending the number 2 to indicate 2NF) PRODUCT-2 (prod-no, prod-desc, unit-price) 4. Rename the original entity (ending with a 2 to indicate 2NF) ORDER-LINE-2 (order-no, prod-no, ord-qty, line-total)

Third Normal Form (3NF) Definition: A relation is in 3NF if, and only if, it is in 2NF and every non-key attribute is non-transitively dependent on the primary key. Remove transitive dependencies into a new relation Steps from 2NF to 3NF: Remove the offending attributes that are transitively dependent on non-key attribute(s), and place them in a new relation. Add to this relation a copy of the attribute(s) which are the determinants of these offending attributes. These will automatically become the primary key of this new relation. Name the new entity (appending the number 3 to indicate 3NF) Rename the original entity (ending with a 3 to indicate 3NF)

Example - 2NF to 3NF ORDER-2 (order-no, order-date, cust-no, cust-name, cust-add, order-total 1. Remove the offending attributes that are transitively dependent on non-key attributes, and place them in a new relation. (cust-name, cust-add ) ORDER-2 (order-no, order-date, cust-no, order-total 2. Add to this relation a copy of the attribute(s) which determines these offending attributes. These will automatically become the primary key of this new relation.. (cust-no, cust-name, cust-add ) ORDER-2 (order-no, order-date, cust-no, order-total 3. Name the new entity (appending the number 3 to indicate 3NF) CUSTOMER-3 (cust-no, cust-name, cust-add ) 4. Rename the original entity (ending with a 3 to indicate 3NF) ORDER-3 (order-no, order-date, cust-no, order-total

Example - Relations in 3NF CUSTOMER-3 (cust-no, cust-name, cust-add ) ORDER-3 (order-no, order-date, cust-no, order-total ORDER-LINE-2 (order-no, prod-no, ord-qty, line-total) PRODUCT-2 (prod-no, prod-desc, unit-price) CUSTOMER ORDER ORDER-LINE PRODUCT places placed by contains part of shows belongs to cust-no order-no prod-no order-no, prod-no