Concepts of Database Management Seventh Edition

Slides:



Advertisements
Similar presentations
Database Design: Normalization J.G. Zheng June 29 th 2005 DB Chapter 4.
Advertisements

Chapter 5 Normalization of Database Tables
5 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Normalization Rules for Database Tables
Chapter 5 Normalization of Database Tables
Chapter 5 Normalization of Database Tables
Relational Terminology. Normalization A method where data items are grouped together to better accommodate business changes Provides a method for representing.
Normalization What is it?
Concepts of Database Management Seventh Edition
1 Class Agenda (04/03 and 04/08)  Review and discuss HW #8 answers  Present normalization process Enhance conceptual knowledge of database design. Improve.
Concepts of Database Management Seventh Edition Chapter 6 Database Design : ERD Model.
Chapter 5 Normalization of Database Tables
Normalization of Database Tables
Chapter 8 Normal Forms Based on Functional Dependencies Deborah Costa Oct 18, 2007.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Concepts of Database Management, 4th Edition, Pratt & Adamski
SQL – Part II Yong Choi School of Business CSU, Bakersfield.
1 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 5 Database Design: Normalization.
Normalization of Database Tables
1 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 5 Database Design 1: Normalization.
NORMALIZATION N. HARIKA (CSC).
Part ( PartNum, Description, OnHand, Class, Warehouse, Price,
Normalization Rules for Database Tables Northern Arizona University College of Business Administration.
Normalization.
Chapter 4: Logical Database Design and the Relational Model (Part II)
Week 6 Lecture Normalization
DBSQL 4-1 Copyright © Genetic Computer School 2009 Chapter 4 Database Design.
Concepts of Database Management Seventh Edition Chapter 5 Database Design 1: Normalization.
A Guide to SQL, Eighth Edition Chapter Two Database Design Fundamentals.
Concepts of Database Management, Fifth Edition Chapter 4: The Relational Model 3: Advanced Topics.
DATABASE LOGICAL DESIGN -- II Chandra S. Amaravadi 1.
SQL – Part II Yong Choi School of Business CSU, Bakersfield.
Relational databases and third normal form As always click on speaker notes under view when executing to get more information!
Concepts of Database Management Seventh Edition Chapter 4 Keys and Relationship.
Normalization - Mr. Ahmad Al-Ghoul Data Design. 2 learning Objectives  Explain the concept of table design  Explain unnormalized design and the first.
Normalization A technique that organizes data attributes (or fields) such that they are grouped to form stable, flexible and adaptive entities.
Module Title? DBMS Normalization. Module Title? DBMS Normalization  Normalization is the process of removing redundant data from tables in order to improve.
Concepts of Database Management Sixth Edition Chapter 5 Database Design 1: Normalization.
Concepts of Database Management, Fifth Edition
1 A Guide to MySQL 2 Database Design Fundamentals.
Concepts of Relational Databases. Fundamental Concepts Relational data model – A data model representing data in the form of tables Relations – A 2-dimensional.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
資料庫正規化 Database Normalization 取材自 AIS, 6 th edition By Gelinas et al.
Database Normalization Lynne Weldon July 17, 2000.
In this chapter, you learn about the following: ❑ Anomalies ❑ Dependency and determinants ❑ Normalization ❑ A layman’s method of understanding normalization.
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.
1 A Guide to MySQL 2 Database Design Fundamentals.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 16 Using Relational Databases.
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.
Concepts of Database Management Seventh Edition Chapter 5 Database Design 1: Normalization.
Concepts of Database Management Seventh Edition Chapter 5 Database Design 1: Normalization.
Concepts of Database Management Seventh Edition Chapter 4 Keys and Relationship.
Microsoft Access 2010 Chapter 11 Database Design.
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.
Normalization ACSC 425 Database Management Systems.
Logical Database Design and Relational Data Model Muhammad Nasir
Southern Methodist University CSE CSE 2337 Introduction to Data Management Chapter 2.
1 First Normal Form (1NF) Unnormalized table : Contains a repeating group –Eg: from multi-valued attributes –Eg: from many-many relationship Table in 1NF:
Copyright © 2016 Pearson Education, Inc. Modern Database Management 12 th Edition Jeff Hoffer, Ramesh Venkataraman, Heikki Topi CHAPTER 4: PART C LOGICAL.
A Guide to SQL, Eighth Edition
Database, tables and normal forms
Normalization Karolina muszyńska
MIS 322 – Enterprise Business Process Analysis
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
Concepts of Database Management Eighth Edition
System Analysis and Design
Normalization – Part II
Yong Choi School of Business CSU, Bakersfield
Chapter 14 Normalization Pearson Education © 2009.
Presentation transcript:

Concepts of Database Management Seventh Edition Chapter 5 Database Design 1: Normalization

Objectives Discuss functional dependence and primary keys Define first normal form, second normal form, and fourth normal form Describe the problems associated with tables (relations) that are not in first normal form, second normal form, or third normal form, along with the mechanism for converting to all three Understand how normalization is used in the database design process

Introduction Normalization process Identifying potential problems, called update anomalies, in the design of a relational database Methods for correcting these problems Normal form: table has desirable properties First normal form (1NF) Second normal form (2NF) Third normal form (3NF)

Introduction (continued) Normalization Table in first normal form better than table not in first normal form Table in second normal form better than table in first normal form, and so on Goal: new collection of tables that is free of update anomalies

Functional Dependence B A A certain field say Column B is functionally dependent on another field say Column A if Column B’s value depend on the value of Column A. And also that Column A’s value is associated only with a exactly one value of Column B. And so if Column B depends on Column A then it also means that Column A functionally determines Column B.

Functional Dependence (continued) Let’s assume that in Premiere Products all Sales Rep in any given Pay class earn the Commission Rate. So, which means a Sale’s Rep Pay Class determines his/her Commission Rate And his/her Commission Rate therefore depends on his/her Pay Class PayClass Rate FIGURE 5-2: Rep table with additional column, PayClass

Functional Dependence (continued) Let’s make it a local example here. Suppose we have a Courses table below: Course Code Course Description IS230 Database Design CA100 Computer Literacy BU101 Intro to Business Course Code Course Description That is, Course Code determines his/her Course Description And Course Description depends on Course Code

Functional Dependence (continued) Given a Salary table for Faculties of a community college which one field determines which field and which field depends which field? Position Annual Salary Instructor 16,000 Assistant Professor 19,000 Associate Professor 24,000 Professor 29,000 Professor Emeritus 35,000

Let us examine Rep table on Premier Database FIGURE 5-3: Rep table FIGURE 5-4: Rep table with second rep named Kaiser added

Is Street functionally depend on Firstname or Lastname? Question? Is Street functionally depend on Firstname or Lastname?

Is CustomerName Functionally Dependent on RepNum? Question? FIGURE 5-3: Rep table Is CustomerName Functionally Dependent on RepNum?

Question? Is QuotedPrice Functionally Dependent on OrderNum? Is QuotedPrice Functionally Dependent on PartNum? So, on which columns does QuotedPrice is functionally dependent?

Non-Graded Exercise Identify which field(s) is functionally dependent on which field(s) And then which field(s) functionally determines which field(s). StudID StudeLast StudFirst HighSchoolNum HighSchoolName AdvisorNum AdvisorName 1 Cruz John 101 CCA 990 Smith 2 Moore Anna 102 SDA 991 Song 3 Friend Fe 4 Zap Mario 103 MNHS 5 Bass Gerard 992 George

Primary Key and Functional Depedence Remember the primary key concept that we learn on Chapter 4? Primary key uniquely identifies a record or row. The key in determining if column is functionally dependent to another column is to ask the question, is a certain column functionally dependent to the Primary Key.

Primary Key and Functional Depedence Is Warehouse functionally dependent on Class? Is the Combination of Partnum and Descriptin is the Primary Key? What is the Primary Key of Part table?

Primary Key and Functional Depedence Is CustomerNum the Primary Key for Customer table? Does CustomerNum determines the values of the other fields?

Question? FIGURE 5-3: Rep table Is OrderNum the Primary Key of OrderLine table? What is the Primary Key of OrderLine Table?

Nothing but the Key The key thought in normalization is the primary key. To Quote E.F. Codd the father of relational database systems. “[Every] non-key [attribute] must provide a fact about the key, the whole key, and nothing but the key.” Take this into mind as we go on three basic normal forms in Database Design.

Three Normal Forms Mnemonics In order to easily remember the three normal forms just remember the word RePeaT ignoring the vowels (which are in small letters) which are: R – 1ST Normal Form - No Repeating groups or multi-valued fields P – 2nd Normal Form - No Partial Dependence T – 3rd Normal Form - No Transitional Dependence

First Normal Form There should be no repeating group or multi-valued columns in order for a Table to be in first normal form. Repeating group: multiple entries for a single record Unnormalized relation: contains a repeating group

First Normal Form (continued) Orders (OrderNum, OrderDate, (PartNum, NumOrdered) ) Multi-valued Columns Multi-valued Columns FIGURE 5-5: Sample unnormalized table

First Normal Form (continued) Orders (OrderNum, OrderDate, PartNum, NumOrdered) Converted to First Normal Form No more Multi-valued fields FIGURE 5-6: Result of normalization (conversion to first normal form)

First Normal Form (continued) Below is a Table students and the course they are taking here at COM: Students StudentID Lastname Firstname Program CoursesTaken 457411 Red Ray CIS IS230, IS220 256742 Zen Anna Education EN210, EN215, EN110 444771 Call Sabrina Business BU250, BU260 Multi-Valued Column Violates 1NF

First Normal Form (continued) To convert to First Normal Form (1NF) is to remove the multi-value column Students StudentID Lastname Firstname Program CoursesTaken 457411 Red Ray CIS IS230, IS220 256742 Zen Anna Education EN210, EN215, EN110 444771 Call Sabrina Business BU250, BU260 X Remove Multi-Value Column

First Normal Form (continued) And create a new Table let’s say named CoursesTaken and relate the two. Students StudentID Lastname Firstname Program 457411 Red Ray CIS 256742 Zen Anna Education 444771 Call Sabrina Business CoursesTaken CourseID StudentID CourseCode 101 457411 IS230 102 IS220 103 256742 ED210 104 ED215 105 EN110 106 444771 BU250 107 BU260

First Normal Form (continued) Below is a Table students and the course they are taking here at COM: CoursesTaken StudentID Lastname Firstname Program CourseCode 222333 Khan Bert CIS IS230 IS220 MS100 Repeating Groups violates 1NF

First Normal Form (continued) To convert to First Normal Form (1NF) is to remove the multi-value column CoursesTaken StudentID Lastname Firstname Program CourseCode 222333 Khan Bert CIS IS230 IS220 MS100 X Remove Repeating Groups

First Normal Form (continued) And create a new Table let’s say named Students and relate the two. CoursesTaken CourseID StudentID CourseCode 101 222333 IS230 102 IS220 103 ED210 Students StudentID Lastname Firstname Program 222333 Khan Bert CIS

Non-Graded Exercise Employees Convert to 1NF the Table below which records the employee and his/her computer skills. Employees EmployeeID Lastname Firstname Gender Computer Skills 1 James George M Encoding, MS Office, Photoshop 2 Miles May F Encoding, Programming, Database Design 3 Gates Alan Programming, MS Office

Non-Graded Exercise Students Convert to 1NF the Table below which records the students and the school club that he/she joins in. Students StudentID Lastname Firstname SchoolClub 88855 Combe Aber Math Club Computer Club 77744 Vibrant Vive Social Club

Second Normal Form (continued) Table (relation) in second normal form (2NF) Table is in first normal form No nonkey column (not a primary key) column should be partially dependent of a composite primary key. Partial dependencies: only on a portion of the primary key

Second Normal Form Primary Key : OrderNum and PartNum OrderDate is partially dependent on OrderNum but not on both OrderNum and PartNum which is the composite Primary Key. Description is partially dependent on PartNum but not on both OrderNum and PartNum which are the composite Primary Key.

Converting to Second Normal Form X OrderNum OrderDate Because the Primary Key is OrderNum and Partnum

Converting to Second Normal Form X Remove partially dependent field OrderDate And make a new table out of it let’s say in this case Orders table

Converting to Second Normal Form X PartNum Description Because the Primary Key is OrderNum and Partnum

Converting to Second Normal Form X Remove partially dependent field Description And make a new table out of it let’s say in this case Part table

Converting to Second Normal Form X X The Original table becomes a new table which is Normalized. And let’s say we name it OderLine table.

Second Normal Form (continued) FIGURE 5-9: Conversion to second normal form

Second Normal Form (continued) Below is a Table of the courses taken by students CourseTaken StudentID Lastname Firstname Program CoursesCode CourseDescription 457411 Red Ray CIS IS230 Database Design CA105 Data Analysis 444771 Call Sabrina Business BU101 Intro to Business Lastname, Firstname, Program are dependent on StudentID but not on CourseCode and StudentID CourseDescription is dependent on CourseCode but not on CourseCode and StudentID

Second Normal Form (continued) To convert to 2NF remove partially dependent fields and make it as another table. CourseTaken StudentID Lastname Firstname Program CoursesCode CourseDescription 457411 Red Ray CIS IS230 Database Design CA105 Data Analysis 444771 Call Sabrina Business BU101 Intro to Business X X Remove Partially Dependent Fields Remove Partially Dependent Field

Second Normal Form (continued) Converting into a new Table those who are partially dependent Students Courses StudentID Lastname Firstname Program 457411 Red Ray CIS 444771 Call Sabrina Business CoursesCode CourseDescription IS230 Database Design CA105 Data Analysis BU101 Intro to Business CoursesTaken StudentID CoursesCode 457411 IS230 CA105 444771 BU101

Non-Graded Exercise CustomersPurchase Convert to 2NF the Table below which Customer’s purchase from which store location. CustomersPurchase CustomerID StoreID StoreLocation 1 Manila 2 Pohnpei 3 4 Hilo LA 5

Third Normal Form (continued) Table (relation) in third normal form (3NF) It is in second normal form There should no non-primary key that is transitional dependent to a primary key.

Third Normal Form (continued) FIGURE 5-10: Sample Customer table

Third Normal Form Customer (CustomerNum, CustomerName, Balance, CreditLimit, RepNum, LastName, FirstName) Functional dependencies: CustomerNum → CustomerName, Balance, CreditLimit, RepNum, LastName, FirstName RepNum → LastName, FirstName

Third Normal Form (continued) Correction procedure Remove each column that is transitionally dependent. Create a new table, transferring the removed columns to the newly created table. Make a primary key of the new table And use the primary key as the foreign key from the table where the columns were removed earlier.

Third Normal Form (continued) FIGURE 5-12: Conversion to third normal form

Third Normal Form (continued) FIGURE 5-12: Conversion to third normal form (continued)

Incorrect Decompositions Decomposition must be done using method described for 3NF Incorrect decompositions can lead to tables with the same problems as original table

Incorrect Decompositions (continued) FIGURE 5-13: Incorrect decomposition of the Customer table

Incorrect Decompositions (continued) FIGURE 5-13: Incorrect decomposition of the Customer table (continued)

Incorrect Decompositions (continued) FIGURE 5-14: Second incorrect decomposition of the Customer table

Incorrect Decompositions (continued) FIGURE 5-14: Second incorrect decomposition of the Customer table (continued)

Third Normal Form (continued) Below is a Table students the program he/she belongs here at COM Students StudentID Lastname Firstname ProgramCode ProgramName 12345 Green Arnel CIS Computer Information Systems 23456 Azure Zenaida GenEd General Education 34567 Brown Country LA Liberal Arts ProgramName is Dependent on ProgramCode not StudentID which is the PK

Third Normal Form (continued) To convert to Third Normal Form (3NF) is to remove the Transitory Dependent column: Students StudentID Lastname Firstname ProgramCode ProgramName 12345 Green Arnel CIS Computer Information Systems 23456 Azure Zenaida GenEd General Education 34567 Brown Country LA Liberal Arts X Remove Transitory Dependent Column

Third Normal Form (continued) And create a new Table out of it let’s say we name it Programs and relate the two. Students StudentID Lastname Firstname ProgramCode 12345 Green Arnel CIS 23456 Azure Zenaida GenEd 34567 Brown Country LA Programs ProgramCode ProgramName CIS Computer Information Systems GenEd General Education LA Liberal Arts

Third Normal Form (continued) Or we could create a new Primary Key for Programs and do like this: Students StudentID Lastname Firstname ProgramID 12345 Green Arnel 1 23456 Azure Zenaida 2 34567 Brown Country 3 Programs ProgramID ProgramCode ProgramName 1 CIS Computer Information Systems 2 GenEd General Education 3 LA Liberal Arts

Non-Graded Exercise Employees Convert to 3NF the Table (i.e. Employees) below which records the Employee’s info including his/her department. Employees EmployeeID Lastname Firstname DepartmentCode DepartmentName 1001 Mills Karen SAL01 Sales North 1002 Courtney Francis SAL02 Sales South 1003 Smith Phillip ENG01 Engineering Design 1005 Xavier Duran ENG02 Engineering Construction 1004 Morrison John

More Practice Exercises

Non-Graded Exercise Let’s say we want to store into a table, Students who are borrowing books from the Library StudentID Lastname Firstname BooksBorrowed 1001 Mills Karen College Algebra, Cooking in Micronesia, Data Analysis 1002 Courtney Francis Statistics, Chronicles of Narnia 1003 Smith Phillip Hermeneutics, Bible Mysteries solved What Normal Form did it violate? How should we normalized the above table?

Non-Graded Exercise Let’s say we want to record the books that Students borrow. And let’s assume that there is already a Table named Students that contains basic information for Students like first name, last name, student ID etc. StudentID DateBorrowed ReturnDate BookNumber BookTitle 22222 09/16/13 09/23/13 BKN13981 War and Peace 23232 09/18/13 09/20/13 XYZ39825 Algorithm 24242 09/12/13 09/19/13 ABC36987 Peace with GOD JIP879874 Incredible Journey What Normal Form did it violate? How should we normalized the above table?

Non-Graded Exercise Let’s say we want to record the Courses that Faculties taught this semester on a Table like one below and CourseAssignID is the Primary Key. Course AssignID FacultyNum Lastname Firstname CourseCode Section 1 2010-12 Ullman Kathy IS230 2 1998-25 Gent Kris EN110 5 3 2013-01 Chiu Ching CA100 4 2008-78 Moore Alexis What Normal Form did it violate? How should we normalized the above table?

Graded Case Study – Alexamara Problem 1 : Normalize the table below which is about owners and the boat(s) they owned OwnerNum LastName FirstName BoatName Weight Marina AD57 Adney Bruce and Jean AdBruce X 1,000 lbs East   Zinger 1,500 lbs AN75 Anderson Bill Yellow Beast 2,000 lbs West BL72 Blake Mary Kumodo 1,200 lbs Kryptonite EL25 Elend Sandy and Bill Shark Fin 1,300 lbs Two Cute 900 lbs Ride North 1,400 lbs

Graded Case Study - Alexamara Problem 2 : Normalize the table below regarding the Boats in Marina Slip and its corresponding owners. SlipID MarinaNum SlipNum Length RentalFee BoatName BoatType OwnerNum OwnerLastName OwnerFirstName 1 A1 40 $3,800.00 Anderson II Sprite 4000 AN75 Anderson Bill 2 A2 Our Toy Ray 4025 EL25 Elend Sand and Bill 3 A3 $3,600.00 Escape KE22 Kelly Allysa 4 B1 30 $2,400.00 Gypsy Dolphin 28 JU92 Juarez Maria 5 B2 $2,600.00 Anderson III Sprite 3000 6 25 $1,800.00 Bravo Dolphin 25 AD57 Adney Bruce and Jean 7 Chinook Dolphin 22 FE82 Feenstra Daniel 8 $2,000.00 Listy SM72 Smeltz Beck and Dave 9 $2,500.00 Mermaid BL72 Blake Mary 10 $4,200.00 Axxon II Dolphin 40 NO27 Norton Peter 11 Karvel TR72 Trent Ashton

Graded Case Study – Henry Books Problem 1 : Normalize the table below regarding Publishers and the Books they published. PublisherCode PublisherName City BookTitle YearPublished AH Arkham House Sauk City WI Dream House 1999   Partial Recall 2011 AP Arcade Publishing New York Games Played 1982 BA Basic Books Boulder CO Dance Fundamentals 1980 Booking the Flight 1993 BP Berkley Publishing Boston Bastketball glory 2001 VB Vintage Books Archive Reload 1998 Rusty Road 2002 WN W.W. Norton War and Breeze 2006 WP Westview Press General Goodwill 1978

Graded Case Study – Henry Books Problem 2 : Normalize the table below regarding Books and their corresponding author. BookCode Title AuthorCode AuthorFirstname AuthorLastname 0180 A Deepness in the Sky 1001 George Graham 0189 Magic Terror 1002 Earl Johnson 0200 The Stranger 0378 Venice 1003 Vitali Pablo 079X Second Wind 1004 Strong Mary 0808 The Edge

Summary Column (attribute) B is functionally dependent on another column A (or collection of columns) when each value for A in the database is associated with exactly one value of B Column(s) A is the primary key if all other columns are functionally dependent on A and no sub-collection of columns in A also have this property

Summary (continued) Table (relation) in first normal form (1NF) does not contain repeating groups Nonkey column (or nonkey attribute) is not a part of the primary key Table (relation) is in the second normal form (2NF) when it is in 1NF and no nonkey column is dependent on only a portion of the primary key Determinant is a column that functionally determines another column

Summary (continued) Table (relation) is in third normal form (3NF) when it is in 2NF and its only determinants are candidate keys Collection of tables (relations) that is not in third normal form has inherent problems called update anomalies