Chapter 7 Normalization. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Modification anomalies Functional dependencies.

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”
N ORMALIZATION Joe Meehean 1. R EDUNDANCIES Repeated data in database Wastes space Can cause modification anomalies unexpected side effect when changing.
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
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.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 9 Advanced Query Formulation with SQL.
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
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 7 Normalization of Relational 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.
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.
Chapter 3 The Relational Model and Normalization
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
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
Concepts of Database Management, Fifth 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.
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.
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 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.
Chapter 3 Query Formulation with SQL. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Background Getting started.
Chapter 9 Advanced Query Formulation with SQL. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Outer join problems.
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
Normalization of Database Tables
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,
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 10 Application Development with Views.
Database Systems, 8 th Edition Improving the Design Table structures cleaned up to eliminate initial partial and transitive dependencies Normalization.
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.
RELATIONAL TABLE NORMALIZATION. Key Concepts Guidelines for Primary Keys Deletion anomaly Update anomaly Insertion anomaly Functional dependency Transitive.
McGraw-Hill/Irwin Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Modeling the Data: Conceptual and Logical Data Modeling.
Week 4 Lecture Part 1 of 3 Normalization of Database Tables Samuel ConnSamuel Conn, Asst. Professor.
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
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.
4NF & MULTIVALUED DEPENDENCY By Kristina Miguel. Review  Superkey – a set of attributes which will uniquely identify each tuple in a relation  Candidate.
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
Relational Model and ER Model: in a Nutshell
Chapter 6 Normalization of Database Tables
* 07/16/96 Normalization 2/16/2019 *.
Presentation transcript:

Chapter 7 Normalization

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Modification anomalies Functional dependencies Major normal forms Relationship independence Practical concerns

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Modification Anomalies Unexpected side effect Insert, modify, and delete more data than desired Caused by excessive redundancies Strive for one fact in one place

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Big University Database Table

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Functional Dependencies Constraint on the possible rows in a table Value neutral like FKs and PKs Asserted Understand business rules

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 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

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. FD Diagrams and Lists StdSSN  StdCity, StdClass OfferNo  OffTerm, OffYear, CourseNo, CrsDesc CourseNo  CrsDesc StdSSN, OfferNo  EnrGrade

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 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

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 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

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Relationships of Normal Forms

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 1NF Starting point for SQL:1999 databases No repeating groups: flat rows

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Combined Definition of 2NF/3NF Key column: candidate key or part of candidate key Analogy to the traditional justice oath Every non key depends on a key, the whole key, and nothing but the key Usually taught as separate definitions

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 2NF Every nonkey column depends on a whole key, not part of a key Violations –Part of key  nonkey –Violations only for combined keys

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 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)

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 3NF Every nonkey column depends only on a key 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

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 3NF Example One violation in UnivTable2 –CourseNo  CrsDesc Splitting the table –UnivTable2-1 (OfferNo, OffTerm, OffYear, CourseNo) –UnivTable2-2 (CourseNo, CrsDesc)

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 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

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. BCNF Example Many violations for the big university database table –StdSSN  StdCity, StdClass –OfferNo  OffTerm, OffYear, CourseNo –CourseNo  CrsDesc Splitting into four tables

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 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.

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Simple Synthesis Example Begin with FDs shown in Slide 7 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

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 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.

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 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

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Relationship Independence Problem

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Relationship Independence Solution

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Extension to the Relationship Independence Solution

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 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

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 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.

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Higher Level Normal Forms 5NF for M-way relationships DKNF: absolute normal form DKNF is an ideal, not a practical normal form

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 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

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 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

McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. 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