1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 4 Normalization.

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.
Chapter 5 Normalization of Database Tables
Chapter 5 Normalization of Database Tables
1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 2 Relational Theory DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH.
Chapter 5 Normalization of Database Tables
Normalization of Database Tables Special adaptation for INFS-3200
Normalization of Database Tables
Chapter 8 Normal Forms Based on Functional Dependencies Deborah Costa Oct 18, 2007.
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 3-1 COS 346 Day 5.
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.
DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH
CS263:Revision on Normalisation
Normalization of Database Tables
Normalization of Database Tables
Normalization of Database Tables
Relational Data Analysis II. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.
© 2002 by Prentice Hall 1 David M. Kroenke Database Processing Eighth Edition Chapter 5 The Relational Model and Normalization.
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 Rules for Database Tables Northern Arizona University College of Business Administration.
Normalization. Introduction Badly structured tables, that contains redundant data, may suffer from Update anomalies : Insertions Deletions Modification.
Normalization of Tables “Between two evils, choose neither; between two goods, choose both.” Tryon Edwards.
Chapter 4: Logical Database Design and the Relational Model (Part II)
XP Chapter 1 Succeeding in Business with Microsoft Office Access 2003: A Problem-Solving Approach 1 Level 3 Objectives: Identifying and Eliminating Database.
Lecture 12 Inst: Haya Sammaneh
Relational databases and third normal form As always click on speaker notes under view when executing to get more information!
Copyright, Harris Corporation & Ophir Frieder, Normal Forms “Why be normal?” - Author unknown Normal.
IT420: Database Management and Organization Normalization 31 January 2006 Adina Crăiniceanu
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
RDBMS Concepts/ Session 3 / 1 of 22 Objectives  In this lesson, you will learn to:  Describe data redundancy  Describe the first, second, and third.
Data Normalization Normal is not something to aspire to, it's something to get away from. ~ Jodie Foster ~
Concepts of Database Management Sixth Edition Chapter 5 Database Design 1: Normalization.
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.
The Relational Model and Normalization R. Nakatsu.
1 DATABASE SYSTEMS DESIGN IMPLEMENTATION AND MANAGEMENT INTERNATIONAL EDITION ROB CORONEL CROCKETT Chapter 7 Normalisation.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
Database Normalization Lynne Weldon July 17, 2000.
Data Normalization Normal is not something to aspire to, it's something to get away from. ~ Jodie Foster ~
DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall, Modified by Dr. Mathis 3-1 David M. Kroenke’s Chapter Three: The Relational.
Normalization Information Systems II Ioan Despi. Informal approach Building a database structure : A process of examining the data which is useful & necessary.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 8 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 8 Creating.
Lecture No 14 Functional Dependencies & Normalization ( III ) Mar 04 th 2011 Database Systems.
ITN Table Normalization1 ITN 170 MySQL Database Programming Lecture 3 :Database Analysis and Design (III) Normalization.
Database Design – Lecture 8
Normalization of Database Tables
Normalizing Your Database CPT 242. Normalization The procedure where the developer analyzes the data and establishes the table structure to create the.
A337 - Reed Smith1 Structure What is a database? –Table of information Rows are referred to as records Columns are referred to as fields Record identifier.
Data Analysis Improving Database Design. Normalization The process of transforming a data model into a flexible, stable structure. Reduces anomalies Anomaly.
Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building.
1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 6 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 6 Creating.
DATA NORMALIZATION CS 260 Database Systems. Overview  Introduction  Anomalies  Functional dependence  Normal forms  1NF  2NF  3NF  BCNF  Denormalization.
Concepts of Database Management Seventh Edition Chapter 5 Database Design 1: 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.
NormalisationNormalisation Normalization is the technique of organizing data elements into records. Normalization is the technique of organizing data elements.
Southern Methodist University CSE CSE 2337 Introduction to Data Management Chapter 5 Part II.
SLIDE 1IS 257 – Fall 2006 Normalization Normalization theory is based on the observation that relations with certain properties are more effective.
What Is Normalization  In relational database design, the process of organizing data to minimize redundancy  Usually involves dividing a database into.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
Adapted from DAVID M. KROENKE’S DATABASE PROCESSING, 10th Edition © 2006 Pearson Prentice Hall 3-1 Functional Dependencies and Normalization.
CSIS 115 Database Design and Applications for Business
Entity relationship diagrams
Presentation transcript:

1 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 DATABASE DESIGN AND DEVELOPMENT: A VISUAL APPROACH Chapter 4 Normalization Raymond Frost – John Day – Craig Van Slyke

2 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Normalized vs. Denormalized Exhibit 4-1: Arcade Database Normalized vs. Denormalized Design

3 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Denormalized Sample Data Exhibit 4-2: Arcade Database Denormalized Sample Data *note the duplicate entries

4 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Denormalized Design Causes Update Problems Exhibit 4-3: Arcade Database Update Problems Due to Duplicate Data When the password for Thom Luce was changed, it was not changed in both his entries. Which password is the correct password?

5 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Normalized Design Eliminates Update Problems Exhibit 4-4: Arcade Database No Update Problem in Normalized Data

6 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Denormalized Design Creates Insert Problems Exhibit 4-5: Arcade Database Insert Problem Due to Duplicate Data A new member cannot be created unless they have already made a visit, otherwise there would be no primary key value. This field may not be left blank.

7 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Normalized Design Eliminates the Insert Problem Exhibit 4-6: Arcade Database No Insert Problem in Normalized Design

8 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Denormalized Design Creates Delete Problems Exhibit 4-7: Arcade Database Delete Problem Due to Duplicate Data If a member makes only one visit, deleting that record will cause the loss of the member data. Deleting visit 005 would cause the loss of Sean McGann’s member data.

9 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Normalized Design Eliminates the Delete Problem Exhibit 4-8: Arcade Database No Delete Problem in Normalized Design Now, deleting visit 005 would not cause the loss of Sean McGann’s member data.

10 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 First Normal Form (1NF) Exhibit 4-9: 1NF Violation Definition: A table in which all fields contain a single value. The example above would be a violation of the 1NF rule; therefore this table would have to be redesigned.

11 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Fixing Normalization Violations Step 1: Tables Step 2: Relationships Step 3: Fields Step 4: Keys -Create new table(s) -Rename original table if necessary - Establish relationships between original and new table(s) - Transfer fields and rename as needed - Choose PK and FK for all tables

12 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Solving a 1NF Violation Exhibit 4-10: Arcade Database Solving the 1NF Violation Step 1: Tables Step 2: Relationships Step 3: Fields Step 4: Keys -Since the phone number column violated the 1NF rule, make a new table to hold phone numbers: DIRECTORY. - A member has multiple phone numbers and a phone number belongs to one member - The phone field is transferred to the DIRECTORY table -The column in MEMBER becomes a FK (MEMBER$ ) in DIRECTORY -The PK in DIRECTORY becomes MEMBER$ and phone since two members could have the same phone number (e.g. two members from the same household).

13 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Tables in 1NF Eliminate Repeating Data Problems Exhibit 4-11: 1NF Solution with Sample Data Now all tables have fields that contain only single values.

14 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Determinants Exhibit 4-12: Primary Key Determines Non-key Fields Determinant: a field or group of fields that controls or determines the values in another field. The value of will determine the values in all the other fields. That is, if you know someone’s , you can determine the rest of their information.

15 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Determinants and Duplicate Data Exhibit 4-13: Acts as a Determinant Exhibit 4-14: Fails to Act as a Determinant When you have duplicate data, knowing someone’s may not allow you to determine the rest of the data as shown below.

16 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Second Normal Form (2NF) Exhibit 4-15: 2NF Violation Definition: A table in which each non-key field is determined by the whole primary key and not part of the primary key by itself. In this example, once you know a student’s id, you can determine his or her name, dorm, and phone. Therefore, the fname, lname, dorm, and phone non-key fields are determined by just part of the primary key: id.

17 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Update Problem Caused by 2NF Violation Exhibit 4-16: 2NF Violation Creates Update Problem Data not determined by the whole primary key will be duplicated and any updates may not be made to all instances of duplicate data. In this example, we no longer know the correct phone number for Jim Green.

18 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Solving a 2NF Violation Exhibit 4-17: Enrollment Database Solving the 2NF Violation Step 1: Tables Step 2: Relationships Step 3: Fields Step 4: Keys -Since only name, dorm, and phone belong in the STUDENT table, create a new table (ENROLL) for the registration information. - A student can enroll in many sections but a particular student-section enrollment relates back to one student. - The SECTION$call_no and grade are information about the enrollment. -The id column in STUDENT becomes a FK (STUDENT$id) in ENROLL. -The PK in ENROLL becomes STUDENT$id and SECTION$call_no.

19 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 All Keys Are Now Determinants Exhibit 4-18: Keys Are Now the Only Determinants All the fields in the STUDENT table are determined by the id. In ENROLL, grade is determined by the student + section.

20 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 2NF Solution with Sample Data Exhibit 4-19: 2NF Solution with Sample Data If you a student’s id, you can determine the values in fname, lname, dorm, and phone. If you know the id of a student and the call_no of a section, you can determine the value of grade.

21 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Third Normal Form (3NF) Exhibit 4-20: 3NF Violation Definition: A table in which none of the non-key fields determine another non-key field. In this example, once you know a member’s , you can determine his or her password, name, and phone number. Therefore, the fname, lname, dorm and phone non-key fields are determined by just part of the primary key: id.

22 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Update Problem Caused by 3NF Violation Exhibit 4-21: 3NF Violation Creates Update Problem By including both member information and visit information in the same table, not all non-key fields are determined by the primary key.

23 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Solving a 3NF Violation Exhibit 4-22: 3NF Solution Step 1: Tables Step 2: Relationships Step 3: Fields Step 4: Keys -Since only password, name, and phone belong in the MEMBER table, create a new table (VISIT) for the visit information. - A member can make many visits, but a particular visit is associated with one member. - The id, date_time_in, and date_time_out are information about the visit, so move them to the VISIT table. -The column becomes the PK in MEMBER. -The column in MEMBER becomes a FK (MEMBER$ ) in VISIT. -The PK in VISIT becomes the session id for the visit.

24 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Keys Are Now Determinants Exhibit 4-23: 3NF Solution – Keys Are Now the Only Determinants All the fields in the MEMBER table are determined by . In VISIT, all non-key fields are determined by id and .

25 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 3NF Solution With Sample Data Exhibit 4-24: 3NF Solution with Sample Data All the non-key fields are determined only by the primary key.

26 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Boyce-Codd Normal Form (BCNF) Exhibit 4-25: BCNF Violation Definition: Every determinant is a key. In this example, there are two fields that could be determinants for an employee: employee_id and ssn.

27 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Update Problem Caused by a BCNF Violation Exhibit 4-26: BCNF Violation Creates Update Problem Since ssn is a non-key field in this table, it can be easily updated, causing incorrect data.

28 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Solving a BCNF Violation Exhibit 4-27: BCNF Solution Step 1: Tables Step 2: Relationships Step 3: Fields Step 4: Keys -Since ssn is really information about the employee, it needs to be in the EMPLOYEE table. - An employee can get many bonuses but a particular bonus belongs to just one employee. - Move the ssn field into the EMPLOYEE table. -The primary key for the EMPLOYEE table is the employee’s id.

29 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Keys Are Now Determinants Exhibit 4-28: BCNF Solution – Keys Are Now the Only Determinants All the fields in the EMPLOYEE table are determined by id. In QUARTERLY_BONUS, all non-key fields are determined by id and quarter.

30 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 BCNF Solution With Sample Data Exhibit 4-29: BCNF Solution With Data All the non-key fields are determined only by the primary key

31 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Fourth Normal Form (4NF) Exhibit 4-30: 4NF Violation Definition: In an all-key table, part of the key can determine multiple values of, at most, one other field. In this example, can determine multiple languages or sports associated with an employee. The double-headed arrow indicates a multivalued dependency: one field determining multiple values of another field.

32 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Update Problem Cause by a 4NF Violation Exhibit 4-31: 4NF Violation Creates Update Problem We could not drop Luce’s German certification without losing his sports information since the primary key requires that all three fields have a value.

33 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Solving a 4NF Violation Exhibit 4-32: 4NF Solution Step 1: Tables Step 2: Relationships Step 3: Fields Step 4: Keys - must be associated with both languages and sports, so create two new tables: LANGUAGE and SPORT. - These tables would not be directly related, but rather, would be related separately to a member table. - Put language and sport in separate tables each time paired with . -The primary key for the LANGUAGE table is and language, -The primary key for the SPORT table is and sport.

34 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 No More Than One Multi-Valued Determinant Exhibit 4-33: 4NF Solution – Only One MVD per Table Each all-key table only has one part of the key that determines multiple values another field.

35 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 4NF Solution with Sample Data Exhibit 4-34: 4NF Solution with Sample Data Now Luce’s German certification can be dropped without losing his sports information.

36 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 Detecting Normalization Violations Exhibit 4-35: Necessary Conditions for Normal Form Violations These are the conditions under with each type of violation can occur.

37 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 ER Diagram for Practice Exercise 1 Exhibit 4-36: ER Diagram for Practice Exercise 1

38 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 ER Diagram for Practice Exercise 2 Exhibit 4-37: ER Diagram for Practice Exercise 2

39 Database Design and Development: A Visual Approach © 2006 Prentice Hall Chapter 4 ER Diagram for Practice Exercise 3 Exhibit 4-38: ER Diagram for Practice Exercise 3