McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 7 Normalization of Relational Tables.

Slides:



Advertisements
Similar presentations
Chapter 5 Normalization of Database Tables
Advertisements

Chapter 5 Normalization of Database Tables
Chapter 5 Normalization of Database Tables
1 Week 4: Normalisation: Redundant data becomes inconsistent data; therefore … “The key, the whole key, and nothing but the key,so help me, Codd”
Shantanu Narang.  Background  Why and What of Normalization  Quick Overview of Lower Normal Forms  Higher Order Normal Forms.
NORMALIZATION FIRST NORMAL FORM (1NF): A relation R is in 1NF if all attributes have atomic value = one value for an attribute = no repeating groups =
Chapter 8 Normalization. © 2001 The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin Outline Modification anomalies Functional dependencies.
Normalization of Database Tables
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.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Developing Data Models for Business Databases.
Normalization of Database Tables
Normalization of Database Tables
Normalization of Database Tables
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 5 The Relational Model and Normalization.
7-1 Normalization - Outline  Modification anomalies  Functional dependencies  Major normal forms  Practical concerns.
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.
Chapter 6 Developing Data Models for Business Databases.
NORMALIZATION N. HARIKA (CSC).
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 3 The Relational Data Model.
Normalization Quiz Tao Li Grant Horntvedt. 1. Which of the following statements is true: a. Normal forms can be derived by inspecting the data in various.
7 Copyright © 2006, Oracle. All rights reserved. Normalization of Relational Tables (Part I)
Chapter 5 Normalization of Database Tables
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 9.1.
Lecture 12 Inst: Haya Sammaneh
Concepts and Terminology Introduction to Database.
CMPE 226 Database Systems September 16 Class Meeting Department of Computer Engineering San Jose State University Fall 2015 Instructor: Ron Mak
Database Systems: Design, Implementation, and Management Tenth Edition
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.
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.
Chapter 7 Normalization. Outline Modification anomalies Functional dependencies Major normal forms Relationship independence Practical concerns.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Chapter 7 Normalization. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Modification anomalies Functional dependencies.
10/3/2012ISC329 Isabelle Bichindaritz1 Logical Design.
Copyright © 2011 by Michael V. Mannino All rights reserved. Database Design, Application Development, and Administration, 5 th Edition Chapter 3 The Relational.
Chapter 2 The Relational Data Model. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Relational model basics Integrity.
Chapter 10 Application Development with Views. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Background Creating.
Database Design, Application Development, and Administration, 5 th Edition Copyright © 2011 by Michael V. Mannino All rights reserved. Chapter 6 Developing.
DataBase Management System What is DBMS Purpose of DBMS Data Abstraction Data Definition Language Data Manipulation Language Data Models Data Keys Relationships.
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
Database Principles: Fundamentals of Design, Implementation, and Management Ninth Edition Chapter 6 Normalization of Database Tables Carlos Coronel, Steven.
Normalization of Database Tables
©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.
Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building.
9/23/2012ISC329 Isabelle Bichindaritz1 Normalization.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 10 Application Development with Views.
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.
Normalisation 1NF to 3NF Ashima Wadhwa. In This Lecture Normalisation to 3NF Data redundancy Functional dependencies Normal forms First, Second, and Third.
Logical Design 12/10/2009GAK1. Learning Objectives How to remove features from a local conceptual model that are not compatible with the relational model.
McGraw-Hill/Irwin Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Modeling the Data: Conceptual and Logical Data Modeling.
Logical Database Design and Relational Data Model Muhammad Nasir
7 Copyright © 2006, Oracle. All rights reserved. Normalization of Relational Tables (Part II)
Normal Forms 1NF – A table that qualifies as a relation is in 1NF. (Back)(Back) 2NF – A relation is in 2NF if all of its nonkey attributes are dependent.
Chapter 2 The Relational Data Model. Outline Relational model basics Integrity rules Rules about referenced rows Relational Algebra.
Chapter 5: Relational Database Design
A brief summary of database normalization
Chapter 4: Relational Database Design
MIS 322 – Enterprise Business Process Analysis
Chapter 9 Designing Databases
Relational Model and ER Model: in a Nutshell
Chapter 6 Normalization of Database Tables
* 07/16/96 Normalization 2/16/2019 *.
Presentation transcript:

McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 7 Normalization of Relational Tables

7-2 Outline  Modification anomalies  Functional dependencies  Major normal forms  Relationship independence  Practical concerns

7-3 Modification Anomalies  Unexpected side effect  Insert, modify, and delete more data than desired  Caused by excessive redundancies  Strive for one fact in one place

7-4 Big University Database Table

7-5 Modification Anomaly Examples  Insertion  Insert more column data than desired  Must know student number and offering number to insert a new course  Update  Change multiple rows to change one fact  Must change two rows to change student class of student S1  Deletion  Deleting a row causes other facts to disappear  Deleting enrollment of student S2 in offering O3 causes loss of information about offering O3 and course C3

7-6 Functional Dependencies  Constraint on the possible rows in a table  Value neutral like FKs and PKs  Asserted  Understand business rules

7-7 FD Definition  X  Y  X (functionally) determines Y  X: left-hand-side (LHS) or determinant  For each X value, there is at most one Y value  Similar to candidate keys

7-8 FD Diagrams and Lists StdSSN  StdCity, StdClass OfferNo  OffTerm, OffYear, CourseNo, CrsDesc CourseNo  CrsDesc StdSSN, OfferNo  EnrGrade

7-9 FDs in Data Prove non existence (but not existence) by looking at data Two rows that have the same X value but a different Y value

7-10 Identifying FDs  Easy identification  Statements about uniqueness  PKs and CKs resulting from ERD conversion  1-M relationship: FD from child to parent  Difficult identification  LHS is not a PK or CK in a converted table  LHS is part of a combined primary or candidate key  Ensure minimality of LHS

7-11 Normalization  Process of removing unwanted redundancies  Apply normal forms  Identify FDs  Determine whether FDs meet normal form  Split the table to meet the normal form if there is a violation

7-12 Relationships of Normal Forms

7-13 1NF  Starting point for most relational DBMSs  No repeating groups: flat rows

7-14 Combined Definition of 2NF/3NF  Key column: candidate key or part of candidate key  Analogy to the traditional justice oath  Every non key column depends on all candidate keys, whole candidate keys, and nothing but candidate keys  Usually taught as separate definitions

7-15 2NF  Every nonkey column depends on all candidate keys, not a subset of any candidate key  Violations  Part of key  nonkey  Violations only for combined keys

7-16 2NF Example  Many violations for the big university database table  StdSSN  StdCity, StdClass  OfferNo  OffTerm, OffYear, CourseNo, CrsDesc  Splitting the table  UnivTable1 (StdSSN, StdCity, StdClass)  UnivTable2 (OfferNo, OffTerm, OffYear, CourseNo, CrsDesc)

7-17 3NF  Every nonkey column depends only on candidate keys, not on non key columns  Violations: Nonkey  Nonkey  Alterative formulation  No transitive FDs  A  B, B  C then A  C  OfferNo  CourseNo, CourseNo  CrsDesc then OfferNo  CrsDesc

7-18 3NF Example  One violation in UnivTable2  CourseNo  CrsDesc  Splitting the table  UnivTable2-1 (OfferNo, OffTerm, OffYear, CourseNo)  UnivTable2-2 (CourseNo, CrsDesc)

7-19 BCNF  Every determinant must be a candidate key.  Simpler definition  Apply with simple synthesis procedure  Special cases not covered by 3NF  Part of key  Part of key  Nonkey  Part of key  Special cases are not common

7-20 BCNF Example  Primary key: (OfferNo, StdSSN)  Many violations for the big university database table  StdSSN  StdCity, StdClass  OfferNo  OffTerm, OffYear, CourseNo  CourseNo  CrsDesc  Split into four tables

7-21 Simple Synthesis Procedure 1.Eliminate extraneous columns from the LHSs 2.Remove derived FDs 3.Arrange the FDs into groups with each group having the same determinant. 4.For each FD group, make a table with the determinant as the primary key. 5.Merge tables in which one table contains all columns of the other table.

7-22 Simple Synthesis Example I  Begin with FDs shown in Slide 8  Step 1: no extraneous columns  Step 2: eliminate OfferNo  CrsDesc  Step 3: already arranged by LHS  Step 4: four tables (Student, Enrollment, Course, Offering)  Step 5: no redundant tables

7-23 Simple Synthesis Example II  AuthNo  AuthName, Auth , AuthAddress  Auth  AuthNo  PaperNo  Primary-AuthNo, Title, Abstract, Status  RevNo  RevName, Rev , RevAddress  Rev  RevNo  RevNo, PaperNo  Auth-Comm, Prog-Comm, Date, Rating1, Rating2, Rating3, Rating4, Rating5

7-24 Simple Synthesis Example II Solution  Author(AuthNo, AuthName, Auth , AuthAddress) UNIQUE (Auth )  Paper(PaperNo, Primary-Auth, Title, Abstract, Status) FOREIGN KEY (Primary-Auth) REFERENCES Author  Reviewer(RevNo, RevName, Rev , RevAddress) UNIQUE (Rev )  Review(PaperNo, RevNo, Auth-Comm, Prog-Comm, Date, Rating1, Rating2, Rating3,Rating4, Rating5) FOREIGN KEY (PaperNo) REFERENCES Paper FOREIGN KEY (RevNo) REFERENCES Reviewer

7-25 Multiple Candidate Keys  Multiple candidate keys do not violate either 3NF or BCNF  Step 5 of the Simple Synthesis Procedure creates tables with multiple candidate keys.  You should not split a table just because it contains multiple candidate keys.  Splitting a table unnecessarily can slow query performance.

7-26 Relationship Independence and 4NF  M-way relationship that can be derived from binary relationships  Split into binary relationships  Specialized problem  4NF does not involve FDs

7-27 Relationship Independence Problem

7-28 Relationship Independence Solution

7-29 Extension to the Relationship Independence Solution

7-30 MVDs and 4NF  MVD: difficult to identify  A  B | C (multi-determines)  A associated with a collection of B and C values  B and C are independent  Non trivial MVD: not also an FD  4NF: no non trivial MVDs

7-31 MVD Representation A  B | C OfferNo  StdSSN | TextNo Given the two rows above the line, the two rows below the line are in the table if the MVD is true.

7-32 Higher Level Normal Forms  5NF for M-way relationships  DKNF: absolute normal form  DKNF is an ideal, not a practical normal form

7-33 Role of Normalization  Refinement  Use after ERD  Apply to table design or ERD  Initial design  Record attributes and FDs  No initial ERD  May reverse engineer an ERD after normalization

7-34 Advantages of Refinement Approach  Easier to translate requirements into an ERD than list of FDs  Fewer FDs to specify  Fewer tables to split  Easier to identify relationships especially M-N relationships without attributes

7-35 Normalization Objective  Update biased  Not a concern for databases without updates (data warehouses)  Denormalization  Purposeful violation of a normal form  Some FDs may not cause anomalies  May improve performance

7-36 Summary  Beware of unwanted redundancies  FDs are important constraints  Strive for BCNF  Use a CASE tool for large problems  Important tool of database development  Focus on the normalization objective