Normalization of Database Tables

Slides:



Advertisements
Similar presentations
Chapter 5 Normalization of Database Tables
Advertisements

Database Tables and Normalization
5 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Normalization of Database Tables
Chapter 5 Normalization of Database Tables
Chapter 5 Normalization of Database Tables
Shantanu Narang.  Background  Why and What of Normalization  Quick Overview of Lower Normal Forms  Higher Order Normal Forms.
1/22/20091 Study the methods of first, second, third, Boyce-Codd, fourth and fifth normal form for relational database design, in order to eliminate data.
Chapter 5 Normalization of Database Tables
Normalization of Database Tables Special adaptation for INFS-3200
Normalization of Database Tables
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
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.
Normalization I.
Normalization of Database Tables
1 Functional Dependency and Normalization Informal design guidelines for relation schemas. Functional dependencies. Normal forms. Normalization.
Normalization of Database Tables
Chapter 5 Normalization of Database Tables
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 5 Normalization of Database Tables.
1 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 5 Database Design 1: Normalization.
Normalization II. Boyce–Codd Normal Form (BCNF) Based on functional dependencies that take into account all candidate keys in a relation, however BCNF.
FUNCTIONAL DEPENDENCIES
Week 6 Lecture Normalization
Lecture 12 Inst: Haya Sammaneh
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,
Database Systems: Design, Implementation, and Management Tenth Edition
Concepts of Database Management, Fifth Edition
Database Management COP4540, SCS, FIU Relation Normalization (Chapter 14)
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 6 Normalization of Database Tables.
The Relational Model and Normalization R. Nakatsu.
Normalization. Learners Support Publications 2 Objectives u The purpose of normalization. u The problems associated with redundant data.
1 DATABASE SYSTEMS DESIGN IMPLEMENTATION AND MANAGEMENT INTERNATIONAL EDITION ROB CORONEL CROCKETT Chapter 7 Normalisation.
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
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.
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
Lecture No 14 Functional Dependencies & Normalization ( III ) Mar 04 th 2011 Database Systems.
Database Design – Lecture 8
1 Functional Dependencies and Normalization Chapter 15.
Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management Peter Rob & Carlos Coronel.
Database Principles: Fundamentals of Design, Implementation, and Management Ninth Edition Chapter 6 Normalization of Database Tables Carlos Coronel, Steven.
Normalization of Database Tables
Design Process - Where are we?
Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building.
E-R Modeling: Table Normalization. Normalization of DB Tables Normalization ► Process for evaluating and correcting table structures determines the optimal.
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,
Normalization.
Database Systems, 8 th Edition Improving the Design Table structures cleaned up to eliminate initial partial and transitive dependencies Normalization.
Brian Thoms.  Databases normalization The systematic way of ensuring that a database structure is suitable for general-purpose querying and free of certain.
Ch 7: Normalization-Part 1
11/10/2009GAK1 Normalization. 11/10/2009GAK2 Learning Objectives Definition of normalization and its purpose in database design Types of normal forms.
Week 4 Lecture Part 1 of 3 Normalization of Database Tables Samuel ConnSamuel Conn, Asst. Professor.
Objectives of Normalization  To create a formal framework for analyzing relation schemas based on their keys and on the functional dependencies among.
ITD1312 Database Principles Chapter 4C: Normalization.
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
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.
Normalization.
Chapter 5: Relational Database Design
Chapter 4: Relational Database Design
Chapter 6 Normalization of Database Tables
Normalization Dale-Marie Wilson, Ph.D..
Normalization of Database Tables Uploaded by: mysoftbooks.ml
Presentation transcript:

Normalization of Database Tables CHAPTER 4 1

Chapter Objectives Understand concepts of normalization Learn how to normalize tables Understand normalization and database design issues 2

Database Tables and Normalization Normalization is a process for assigning attributes to entities. It reduces data redundancies. An un-normalized relation (table) stores redundant data, which can cause insertion, deletion, and modification anomalies. In simple words: Normalization means keeping a single copy of data in your database. Normalization theory provides a step by step method to remove redundant data and undesirable table structures. 4

Normal Forms Tables are normalized by applying rules to create a series of normal forms: First normal form (1NF) Second normal form (2NF) Third normal form (3NF) Boyce/Codd normal form (BCNF) Fourth normal form (4NF) Projection Join normal form (PJNF, aka 5NF) A table or relation in a higher level normal form always confirms to lower level normal forms.

Normal Forms PJ/NF (5NF) Relations 4NF Relations BCNF Relations 3NF Relations 2NF Relations 1NF Relations While higher level normal forms are available, normalization up to BCNF is often found to be adequate for business data.

First Normal Form A relation is in 1NF if all underlying domains contain atomic values only, i.e., the intersection of each row and column contains one and only one value. The relation must not contain repeating groups. PNo PName ENo EName Jcode ChgHr Hrs 1 Alpha 101 John Doe NE $65 20 105 Jane Vo SA $80 15 110 Bob Lund CP $60 40 2 Beta 101 John Doe NE $65 20 108 Jeb Lee NE $65 15 106 Sara Lee SA $80 20 3 Omega 102 Beth Reed PM $125 20 105 Jane Vo SA $80 10 Is the above relation in 1NF? 9

First Normal Form The previous relation can be converted into first normal form by adding Pno and Pname to each row. PNo PName ENo EName Jcode ChgHr Hrs 1 Alpha 101 John Doe NE $65 20 1 Alpha 105 Jane Vo SA $80 15 1 Alpha 110 Bob Lund CP $60 40 2 Beta 101 John Doe NE $65 20 2 Beta 108 Jeb Lee NE $65 15 2 Beta 106 Sara Lee SA $80 20 3 Omega 102 Beth Reed PM $125 20 3 Omega 105 Jane Vo SA $80 10 What is the primary key in this relation? Do you see redundant data in this table? What anomalies could be caused?

Functional Dependency Revisited If A and B are attributes (or group of attributes) of a relation R, B is functionally dependent on A (denoted A B), if each value of A in R is associated with exactly one value of B in R. A is called a determinant. Consider the relation Student (ID, Name, Soc Sec Nbr, Major, Deptmt) Assume a department offers several majors, e.g. INSY department offers, INSY, MASI, and POMA majors. How many determinants can you identify in Student?

Functional Dependency Revisited A Dependency diagram ID Name Soc_Sec_Nbr Major Dept

Functional Dependency Revisited Full functional dependency Attribute B is fully functionally dependent on attribute A if it is functionally dependent on A and not functionally dependent on any proper subset of A. This becomes an issue only with composite keys. Transitive dependency A, B and C are attributes of a relation such that 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)

Second Normal Form Dependency diagram for Project PNo PName ENo EName JCode ChgHr Hrs

Second Normal Form A relation is in 2NF if: It is in 1NF and every nonkey attribute is fully dependent on the primary key, i.e., no partial dependency. A nonkey attribute is one that is not a primary key or part of a primary key. We create new relations that are in 2NF through projection of the original relation. Project(PNo, PName) Employee(ENo, EName, Jcode, ChgHr) Charge(PNo, ENo, Hrs) 14

2NF 2NF PNo PName ENo EName JCode ChgHr PNo ENo Hrs

Second Normal Form Tables in 2NF Charge PNo ENo Hrs 1 101 20 Project 1 101 20 1 105 15 1 110 40 2 101 20 2 108 15 2 106 20 3 102 20 3 105 10 Project PNo PName 1 Alpha 2 Beta 3 Omega Employee ENo EName JCode ChgHr 101 John Doe NE $65 102 Beth Reed PM $125 105 Jane Vo SA $80 106 Sara Lee SA $80 108 Jeb Lee NE $65 110 Bob Lund CP $60

Second Normal Form Note that the original relation can be recreated through natural join of the new relation. Thus, no information is lost in the process of creating 2NF relations from a 1NF relation. This is called nonloss decomposition. If a relation that is in 1NF has a non composite primary key (i.e., the primary key consists of a single attribute) what can you say about its status with regard to 2NF? Do you see any redundant data in the tables that are in 2NF? What anomalies could be caused by such redundancy?

Third Normal Form A relation is in 3NF if: It is in 2NF and every nonkey attribute is nontransitively dependent on the primary key (i.e., no transitive dependency). Relation Employee has a transitive dependency: ENo JCode ChgHr Employee can be replaced by two relations, that are in 3NF: Employee(ENo, EName, Jcode) Job(JCode, ChgHr) 16

3NF 3NF PNo PName JCode ChgHr ENo EName JCode PNo ENo Hrs

Third Normal Form Tables in 3NF Charge PNo ENo Hrs 1 101 20 Project 1 101 20 1 105 15 1 110 40 2 101 20 2 108 15 2 106 20 3 102 20 3 105 10 Project PNo PName 1 Alpha 2 Beta 3 Omega Employee ENo EName Jcode 101 John Doe NE 102 Beth Reed PM 105 Jane Vo SA 106 Sara Lee SA 108 Jeb Lee NE 110 Bob Lund CP Job Jcode ChgHr CP $60 NE $65 PM $125 SA $80

Boyce-Codd Normal Form A relation is in BCNF if every determinant is a candidate key. A determinant is an attribute (combination of attributes) on which some other attribute is fully functionally dependent. BCNF is a special case of 3NF. The potential to violate BCNF may occur in a relation that: contains two (or more) composite candidate keys, these keys overlap and share at least one attribute. Thus, if a table contains only one candidate key or only non-composite keys, then 3NF and BCNF are equivalent. 18

3NF Table Not in BCNF Figure 4.7

Decomposition of Table Structure to Meet BCNF Figure 4.8

Boyce-Codd Normal Form Consider the following example: The members of a recruiting team interview candidates on a one-to-one basis. Each member is assigned a particular room on a given date. Each candidate is interviewed only once on a specific date. He/she may return for follow up interviews on later dates. Interview (CID, IDate, ITime, StaffID, RmNo) CID IDate ITime StaffID RmNo C01 8-22-99 10:00 S01 B107 C02 8-22-99 11:00 S01 B107 C03 8-22-99 10:00 S05 B108 C01 8-29-99 3:00 S06 B108

Boyce-Codd Normal Form This relation has following functional dependencies: CID, IDate ITime, StaffID, RmNo StaffID, IDate, ITime CID, RmNo RmNo, Idate, Itime StaffID, CID StaffID, IDate RmNo This relation does not have any partial or transitive dependencies on the primary key (CID, IDate) It is not in BCNF because (StaffID, Idate) is a determinant but not a candidate key. The new relations in BCNF are: Interview (CID, IDate, ITime, StaffID) Room(StaffID, IDate, RmNo)

Dependency Diagram Fig 1 Fig 2 Fig 3 CID IDate ITime StaffID RmNo CID

Fourth Normal Form A table is in 4NF if it is in 3NF and has no multiple sets of multivalued dependencies. Consider the following example: Each course is taught by many teachers and requires many texts. CTXU (Unnormalized) Course Teacher Text Physics Green Basic Mechanics Brown Intro to Optics Math White Modern Algebra Intro to Calculus CTXN (Normalized) Course Teacher Text Physics Green Basic Mechanics Physics Green Intro to Optics Physics Brown Basic Mechanics Physics Brown Intro to Optics Math White Modern Algebra Math White Intro to Calculus 30

Fourth Normal Form CTXN is in BCNF, because it is all key and there are no other functional dependencies. It, however, has redundant data that could cause update anomalies. This table shows two multivalued dependencies: Each course has a defined set of teachers and Course Teacher Each course has a defined set of textbooks. Course Text MVDs can exist only when the relation has at least three attributes. An FD is a special case of MVD when the set of dependent values has a single value.

Fourth Normal Form Tables in 4NF CX CT Course Text Course Teacher Physics Green Physics Brown Math White CX Course Text Physics Basic Mechanics Physics Intro to Optics Math Modern Algebra Math Intro to Calculus

Conversion to 4NF Figure 4.15 Set of Tables in 4NF Figure 4.14 Multivalued Dependencies

Normalization and Database Design Normalization should be part of the design process E-R Diagram provides macro view Normalization provides micro view of entities Focuses on characteristics of specific entities May yield additional entities Difficult to separate normalization from E-R diagramming Business rules must be determined Normalization purity is difficult to sustain due to conflict in: Design efficiency Information requirements Processing

Denormalization Normalized (decomposed) tables require additional processing, thus reducing system speed. Sometimes normalization is not done keeping in mind processing speed requirements and practical aspects of the situation. A good example is: storing Zip code and City as attributes in a Customer relation violates 3NF because City is transitively dependent on Cust ID via Zip Code. Why should we not create a separate relation ZIP (ZipCode, City)? 32