Normalisation The theory of Relational Database Design.

Slides:



Advertisements
Similar presentations
ER to Relational Mapping. Logical DB Design: ER to Relational Entity sets to tables. CREATE TABLE Employees (ssn CHAR (11), name CHAR (20), lot INTEGER,
Advertisements

Functional Dependencies and Normalization for Relational Databases
Defined by Edgar Codd in 1970 Defined by Edgar Codd in 1970 Considered ingenious but impractical Considered ingenious but impractical Conceptually simple.
Normalization Dr. Mario Guimaraes. Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints.
Ch 10, Functional Dependencies and Normal forms
Functional Dependencies and Normalization for Relational Databases.
Normalization of Database Tables Special adaptation for INFS-3200
Design Guidelines Normalisation Table Design. Informal Design Guidelines Table Semantics A table should hold information about one and only one entity/concept.
11. Normalization Database Design is the process of finding a "good" logical structure for the database. So far, design has been maintaining well-defined.
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
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
Normalization of Database Tables
Databases 6: Normalization
NORMALIZATION N. HARIKA (CSC).
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Normalization of relational database Data redundance Second Normal Form Third Normal Form Forth Normal Form.
Week 6 Lecture Normalization
Functional Dependencies
Dr. T. Y. Lin | SJSU | CS 157A | Fall 2015 Chapter 3 Database Normalization 1.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Concepts and Terminology Introduction to Database.
Logical Database Design ( 補 ) Unit 7 Logical Database Design ( 補 )
NormalizationNormalization Chapter 4. Purpose of Normalization Normalization  A technique for producing a set of relations with desirable properties,
RDBMS Concepts/ Session 3 / 1 of 22 Objectives  In this lesson, you will learn to:  Describe data redundancy  Describe the first, second, and third.
King Saud University College of Computer & Information Sciences Computer Science Department CS 380 Introduction to Database Systems Functional Dependencies.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
Database Design (Normalizations) DCO11310 Database Systems and Design By Rose Chang.
Normalization Database Design is the process of finding a "good" logical structure for the database. So far, design criteria has been just maintaining.
Logical Database Design Relational Model. Logical Database Design Logical database design: process of transforming conceptual data model into a logical.
SALINI SUDESH. Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of.
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
Chapter 7 1 Database Principles Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that.
Functional Dependencies and Normalization for Relational Databases.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
Normalization Ioan Despi 2 The basic objective of logical modeling: to develop a “good” description of the data, its relationships and its constraints.
How to build ER diagrams
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.
1 Functional Dependencies and Normalization Chapter 15.
©NIIT Normalizing and Denormalizing Data Lesson 2B / Slide 1 of 18 Objectives In this section, you will learn to: Describe the Top-down and Bottom-up approach.
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.
Normalization.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
Brian Thoms.  Databases normalization The systematic way of ensuring that a database structure is suitable for general-purpose querying and free of certain.
Logical Database Design and the Relational Model.
Ch 7: Normalization-Part 1
Normalisation 1NF to 3NF Ashima Wadhwa. In This Lecture Normalisation to 3NF Data redundancy Functional dependencies Normal forms First, Second, and Third.
Lecture 4: Logical Database Design and the Relational Model 1.
Al-Imam University Girls Education Center Collage of Computer Science 1 st Semester, 1432/1433H Chapter 10_part 1 Functional Dependencies and Normalization.
11/06/97J-1 Principles of Relational Design Chapter 12.
Objectives of Normalization  To create a formal framework for analyzing relation schemas based on their keys and on the functional dependencies among.
Advanced Database System
Logical Database Design and Relational Data Model Muhammad Nasir
SLIDE 1IS 257 – Fall 2006 Normalization Normalization theory is based on the observation that relations with certain properties are more effective.
Database Normalization. What is Normalization Normalization allows us to organize data so that it: Normalization allows us to organize data so that it:
Chapter 14 Functional Dependencies and Normalization Informal Design Guidelines for Relational Databases –Semantics of the Relation Attributes –Redundant.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Dr. T. Y. Lin | SJSU | CS 157A | Fall 2015 Chapter 3 Database Normalization 1.
COP 6726: New Directions in Database Systems
Functional Dependency and Normalization
Normalization Karolina muszyńska
Chapter 5: Logical Database Design and the Relational Model
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Database Management systems Subject Code: 10CS54 Prepared By:
Normalization.
Unit 7 Normalization (表格正規化).
Normalization February 28, 2019 DB:Normalization.
Database Normalisation
Sampath Jayarathna Cal Poly Pomona
Presentation transcript:

Normalisation The theory of Relational Database Design

Introduction Normalisation is a theory for designing relational schema that “make sense” and work well. Well-normalised tables avoid redundancy and thereby reduce inconsistencies. Redundancy is unnecessary duplication. In well-normalised DBs semantic dependencies are maintained by primary key uniqueness.

Goals of Normalisation Eliminate certain kinds of redundancy avoid certain update anomalies good reresentation of real world simplify enforcement of DB integrity

Update anomalies Undesirable side-effects that occur when performaing insertion, modification or deletion operations on badly designed relational DBs. SSN Name J Smith M Burke A Dolan K Doyle O O’Neill R McKay Dept DeptMgr Representing Department info in the Employee table causes problems. Dept Name …...

Sample anomalies Modification - –when the manager of a dept changes we have to change many values. –If we are not careful the DB will contain inconsistencies. –There is no easy way to get the DB to ensure that a department has only one manager and only one name.

Anomalies continued Deletion - –if O O’Neill leaves we delete his tuple and lose the fact that there is a department 3 the name of dept 3 who is the manager of dept. 3 Insertion –how would we create a new department before any employees are assigned to it ?

Better design Separate entities are represented in separate tables. SSN Name J Smith M Burke A Dolan K Doyle O O’Neill R McKay Dept Dept DeptMgr Dept Name …... Note that mapping from an ER model following the steps given will give a well-normalised DB.

Boyce-Codd Normal Form After a lot of other approaches Boyce and Codd noticed a simple rule for ensuring tables are well-normalised. Tables which obey the rule are in BCNF (Boyce Codd Normal Form). BCNF rule: Every determinant in a table must be a candidate key for that table.

Determinants A is a determinant of B if each value of A has precisely one (possibly null) associated value of B. Said another way - A is a determinant of B if and only if whenever two tuples agree on their A value they agree on their B value. AB

Determinants Note that determinancy depends on semantics of data –cannot be decided from individual table occurences. Alternative terminology –if A (functionally) determines B then –B is (functionally) dependent on A

Example determinants SSN determines employee name SSN determines employee department Dept. No. determines Dept. Name Dept. Name determines Dept. No. –assuming Dept. names are also unique Emp. Name does not determine Emp. Dept –two John Smiths could be in difft. Depts. Emp. Name does not determine SSN.

Determinancy Diagram SSN Name Department Dept. Name Dept. Mgr In general key attributes of an entity determine all the single-valued attributes of the entity.

Composite Determinants (SSN, Project#) together determine the hours that the employee works on the project. Suppose packsize of a part depends on the supplier. SSN Project# hours PName Name S# P# packsize PName

Superfluous Attrbiutes Superfluous attributes –If SSN determines name, so does (SSN, Dept) and (SSN, Dept, salary), etc. –Always remove superfluous attributes from determinants.

Transitive Dependencies SSN actually determines DeptMgr but only because –SSN determines DeptNo and –DeptNo determines DeptMgr. Be careful to remove transitive dependencies. –They mess up normalisation. SSN DeptNo Dept. Mgr

Candidate keys candidate key = any attribute or set of attributes which will be unique for a table (set of attributes). –As well as the primary key there may be other candidate keys. –E.g. DNUMBER and DNAME are both candidate keys for the Department table. Key = row identifier Candidate key = candidate identifier

Finding candidate keys Every key is by definition a determinant of all other attributes in a relation. –So in a diagram, any attribute (or composite) from which all other attributes are reachable is a candidate key. SSN Project# hours PName Name (SSN, Project#) is a (composite) candidate key for a table containing these five attributes.

What are the candidate keys ? D E F GHJ K L M N PQ R S T U student subject teacher V W X Y A Z C B B D F E G H

Problems occur when... Redundancy and anomalies occur when there are determinants which are not candidate keys. SSN Name DeptNo Dept. Name Dept. Mgr SSN is the only key for a table containing these attributes –all attributes are reachable from SSN. SSN, DeptNo and DeptName are determinants –they have arrows coming out of them.

BCNF rule In well-normalised relations (Boyce-Codd normal form) every determinant is a candidate key. SSN Name DeptNo Dept. Name Dept. Mgr DeptNo The employee/dept table decomposed to BCNF. Note that both DeptNo and DeptName are candidate keys of the second table.

Transformation to BCNF Create new tables such that each non-key determinant is a candidate key in a new table. The new table contains the attributes which are directly determined by the new candidate key. V W X Y A Z C B V X V W Y V W A Z A C B BCNF tables : (V, X) (A, B, C) (V, W, Z, A) (V, W, Y)

Other Normal Forms First NF - no multi-valued attributes –all relational DBs are 1NF 2NF - every non-key attribute is fully dependent on the primary key 3NF - eliminate functional dependencies between non-key attributes –all dependencies can then be enforced by uniqueness of keys. GHJ Table is in 2NF but not 3NF

BCNF vs. 3NF BCNF goes further than 3NF, some say too far. A 3NF table that has no overlapping composite keys is in BCNF. student subject teacher 3NF, not BCNF keys: (student, subject) (student, teacher) teacher is a determinant studentteacher subjectteacher BCNF but tables are not independent A teacher teaches only one subject. For a given subject a given student has only one teacher.

4NF : Multi-valued dependencies If a course can have multiple teachers and multiple texts, blind mapping to 1NF will give Subject Physics Maths Teacher Green Brown Green Brown Green Text Basic Mechanis Basic Mechanics Principles of Optics Basic Mechanics Vector Analysis Trigonometry which clearly has redundancy.

Fully-normalised BCNF relations are well-normalised Fully-normalised relations are those with no multi-valued dependencies (4NF) and no join dependencies (5NF).