Normalization Rules for 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.
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?
1 Logical Database Design and the Relational Model Modern Database Management.
Athabasca University Under Development for COMP 200 Gary Novokowsky
Normalization of Database Tables
Systems Development Life Cycle
© 2005 by Prentice Hall 1 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 7 th Edition Jeffrey A. Hoffer, Mary B.
© 2005 by Prentice Hall Chapter 3a Database Design Modern Systems Analysis and Design Fourth Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
The Relational Database Model:
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Chapter 5 Normalization of Database Tables
Normalization A337. A337 - Reed Smith2 Structure What is a database? ◦ Tables of information  Rows are referred to as records  Columns are referred.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 5 Normalization of Database Tables.
© 2007 by Prentice Hall 1 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 8 th Edition Jeffrey A. Hoffer, Mary B.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Normalization Rules for Database Tables Northern Arizona University College of Business Administration.
Chapter 5 Normalization of Database Tables
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 9.1.
Chapter 4: Logical Database Design and the Relational Model (Part II)
Week 6 Lecture Normalization
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Chapter 1 Overview of Database Concepts Oracle 10g: SQL
Concepts and Terminology Introduction to Database.
Chapter 5: Logical Database Design and the Relational Model
Normalization A technique that organizes data attributes (or fields) such that they are grouped to form stable, flexible and adaptive entities.
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.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
Logical Database Design Relational Model. Logical Database Design Logical database design: process of transforming conceptual data model into a logical.
Chapter 7 1 Database Principles Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that.
10/3/2012ISC329 Isabelle Bichindaritz1 Logical Design.
CIS 210 Systems Analysis and Development Week 6 Part II Designing Databases,
Unit 4 Object Relational Modeling. Key Concepts Object-Relational Modeling outcomes and process Relational data model Normalization Anomalies Functional.
Copyright 2006 Prentice-Hall, Inc. Essentials of Systems Analysis and Design Third Edition Joseph S. Valacich Joey F. George Jeffrey A. Hoffer Chapter.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
Database Design – Lecture 8
Normalization of Database Tables
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.
Logical Database Design and the Relational Model.
Chapter 10 Designing Databases. Objectives:  Define key database design terms.  Explain the role of database design in the IS development process. 
1 Class Agenda (04/06/2006 and 04/11/2006)  Discuss use of Visio for ERDs  Learn concepts and ERD notation for data generalization  Introduce concepts.
1 © Prentice Hall, 2002 ITD1312 Database Principles Chapter 4B: Logical Design for Relational Systems -- Transforming ER Diagrams into Relations Modern.
Logical Database Design and the Relational Model.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 7 Normalization Hour1,2 Presented & Modified by Mahmoud Rafeek Alfarra.
6-1 © Prentice Hall, 2007 Topic 6: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
8-1 © Prentice Hall, 2007 Chapter 8: Object-Relational Modeling Object-Oriented Systems Analysis and Design Joey F. George, Dinesh Batra, Joseph S. Valacich,
Lecture 4: Logical Database Design and the Relational Model 1.
Logical Design 12/10/2009GAK1. Learning Objectives How to remove features from a local conceptual model that are not compatible with the relational model.
NormalisationNormalisation Normalization is the technique of organizing data elements into records. Normalization is the technique of organizing data elements.
NORMALIZATION Handout - 4 DBMS. What is Normalization? The process of grouping data elements into tables in a way that simplifies retrieval, reduces data.
Chapter 4 © 2013 Pearson Education, Inc. Publishing as Prentice Hall Chapter 4: Logical Database Design and the Relational Model Modern Database Management.
Normalizing Database Designs. 2 Objectives In this chapter, students will learn: –What normalization is and what role it plays in the database design.
Logical Design & the Relational Model
Chapter 4 Logical Database Design and the Relational Model
Chapter 5: Logical Database Design and the Relational Model
MIS 322 – Enterprise Business Process Analysis
Example Question–Is this relation Well Structured? Student
Chapter 9 Designing Databases
Normalization A337.
Chapter 5: Logical Database Design and the Relational Model
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Presentation transcript:

Normalization Rules for Database Tables Normalization Rules for Database Tables Northern Arizona University College of Business Administration

Normalization - Some Definitions Normalization - Some Definitions a relation is a two-dimensional array with a single-valued entry in each cell which has no duplicate rows and has columns whose meaning is the same across all rows. All tables used in the relational model must be relations. Normalization is a process for evaluating table structure and reorganizing them as needed to product a set of stable, well-structured relations. An anomaly is a condition which interferes with the storage, or retention of data or creates the potential for inconsistent data. There are insertion, modification, and deletion anomalies. The Normalization process should eliminate anomalies.

Unnormalized Tables An Unnormalized table is a table that does not meet the definition of a relation. it contains rows with multiple values for an attribute (repeating groups) or contains duplicate rows. A table is said to be in first normal form if it meets the definition of a relation Generally this means it contains no repeating groups of attributes. The next slide shows an example of an unnormalized table.

EMPLOYEE This EMPLOYEE table is unnormalized - It has cells that do not contain single-valued entries. As shown this table has no logical primary key. The E ID# does not functionally determine the value of Skill.

EMPLOYEE The above employee table shows the same set of data as the previous slide. It has been reorganized into a form that could be implemented under some file processing systems, using COBOL, for instance. However, it is still not in a form that can be used by the relational model. The Skills are a multi-valued (repeating group) of attributes which cannot be identified by the primary key.

Eliminating Repeating Groups Original Table EMPLOYEE In most cases, Unnormalized tables can be converted to Sets of Tables that are in at least First Normal form by: placing any repeating groups of fields in a separate table which includes the primary key attribute from the original table along with a single occurrence of the repeating attribute (Skill in our example). A Table is in first normal form if it contains no multi-valued attributes

Eliminating Repeating Groups EMPLOYEE Original Normalized EMPLOYEE_SKILL EMPLOYEE

Logical ER Diagram in ER Studio Notation 1st Normal Form Example

This Table is in First Normal Form This Table is in First Normal Form Schedule of Classes There are no repeating groups of attributes. NOTE: The primary key of this table is a Concatenated key - no single attribute uniquely identifies a row of the table, but the Combination of Course # and Section # does uniquely identify a row. If I know that the Course is CIS 120 and the Section is section 1, I can identify a unique schedule occurrence.

Although this Table is in First Normal Form, it Contains Anomalies Although this Table is in First Normal Form, it Contains Anomalies Schedule of Classes If the description of CIS220 Changes from VB Prog. to Visual C#, I must record the new value in two places (as shown) - This is a modification anomaly

Although this Table is in First Normal Form, it Contains Anomalies Although this Table is in First Normal Form, it Contains Anomalies ? Schedule of Classes If a new course has been designed and I know its description and credit hours (ACC 266, Pers. Acc., 2 hrs), I still cannot record this data until at least one section of the course is offered - an insertion anomaly.

A Table in First Normal Form Containing Anomalies A Table in First Normal Form Containing Anomalies Schedule of Classes If no section of ACC 255 is offered this semester, I will lose the information about the description and credit hours of this course. - A deletion anomaly

Schedule of Classes This table has anomalies because it contains partial dependencies. A partial dependency occurs when one or more attributes in a table depends upon (is functionally determined by) only a portion of a concatenated primary key. In this case the Description and Cr. Hrs. attributes depend only on Course #. To correct this problem, those attributes determined by only a part of the key should be placed in a separate table. Its Primary key will be the portion of the original primary key required to identify them.

Schedule of Classes Original Revised Schedule of Classes COURSE Notice how this structure eliminates the anomalies we found

Logical ER Diagram in ER Studio Notation 2nd Normal Form Example

Second Normal Form Partial Dependencies occur when nonkey attributes are functionally determined by only a portion of a concatenated primary key. Partial dependencies can occur only in tables with a concatenated key. Partial dependencies can be corrected by removing those attributes to a separate table whose primary key is just the portion of the key from the original table needed to functionally determine them. A table is in second Normal Form if it is in first normal form and it contains no partial dependencies.

A Table in Second Normal Form Which Has Anomalies PROFESSOR This table is in 2nd normal form since it has no repeating groups of attributes (first normal form) and its primary key is not concatenated. However, the table above still has anomalies.

Anomalies in the Example Professor Table PROFESSOR Modification Anomalies -if the Dept Aide serving the ECO department changes, or if the Fax # of the ECO department changes, this change would need to be made in several records. Insertion Anomalies - I want to start a new department and have a Dept Code, a Dept Aide, and a Dept Fax # (e.g., MKT, T. Taylor, 523-7216). I can’t add this data to the table until at least one professor is hired to teach in this new department.

Anomalies in the Example Professor Table PROFESSOR Deletion Anomalies - If Prof # L29 (the only professor in the CIS department in our example table) is deleted, we would lose the information about the name of the Dept Aide for CIS and the Dept Fax # for CIS.

This Professor Table has Transitive Dependencies PROFESSOR The anomalies we have found occur because the Professor table has transitive dependencies. Dept Code, Dept Aide, and Dept Fax # are all attributes of a DEPARTMENT entity which is uniquely identified by Dept Code - If I know Dept Code I can uniquely identify Dept Aide and Dept Fax #. Knowing Prof # allows me to identify these attributes, but only through a chain of inferences - Prof # uniquely identifies Dept Code which, in turn uniquely identifies the other DEPARTMENT attributes. The anomalies can be resolved by removing the attributes determined by a non-key attribute to a separate table.

Correcting Transitive Dependencies PROFESSOR Original Revised PROFESSOR DEPARTMENT

Logical ER Diagram in ER Studio Notation 3rf Normal Form Example

Third Normal Form Transitive dependencies occur when non-key attributes are functionally determined by other non-key attributes. Transitive dependencies can be corrected by removing the attributes to a separate table whose primary key is the attribute of the original table which functionally determines them. The functionally determining attribute serves as a foreign key in the original table. A table is in Third Normal Form if it is in second normal form and it contains no transitive dependencies.

A Proposed Normalization Process for Database Designers A Proposed Normalization Process for Database Designers Examine each table of the proposed structure and perform the following operations: Remove any repeating groups of attributes (multi-valued attributes) to a separate table. If there are independent sets of multi-valued attributes place each set in a separate table. Remove any attributes that are functionally determined by only a portion of a concatenated key to a separate table. Remove any attributes that are functionally determined by a non-key attribute to a separate table.

Review Question: What Normalization rule(s) are violated by the table below? How would you revise the table Structure? Write out your answer on a piece of scratch paper.

Review Question Solution: Review Question Solution: This table violates both 2nd & 3rd normal forms. Emp. Name and Emp. Class both depend only on Emp No. Which is part of the concatenated key - violates 2nd normal form. Wage Rate is actually determined by Emp Class a non-key attribute which violates 3rd normal form. Original Table: Normalized Tables Employee Class Employee Hours Employee

Logical ER Diagram in ER Studio Notation Review Question Example

Merging Relations View Integration–Combining entities from multiple ER models into common relations Issues to watch out for when merging entities from different ER models: Synonyms–two or more attributes with different names but same meaning Homonyms–attributes with same name but different meanings Transitive dependencies–even if relations are in 3NF prior to merging, they may not be after merging Supertype/subtype relationships–may be hidden prior to merging

Enterprise Keys Primary keys that are unique in the whole database, not just within a single relation Corresponds with the concept of an object ID in object-oriented systems

Figure 4-31 Enterprise keys a) Relations with enterprise key b) Sample data with enterprise key

Mapping Unary Relationships One-to-Many–Recursive foreign key in the same relation Many-to-Many–Two relations: One for the entity type One for an associative relation in which the primary key has two attributes, both taken from the primary key of the entity

Figure 4-17 Mapping a unary 1:N relationship (a) EMPLOYEE entity with unary relationship (b) EMPLOYEE relation with recursive foreign key ER Studio Notation

Figure 4-17 Mapping a unary 1:N relationship (a) EMPLOYEE entity with unary relationship (b) EMPLOYEE relation with recursive foreign key

Figure 4-18 Mapping a unary M:N relationship (a) Bill-of-materials relationships (M:N) (b) ITEM and COMPONENT relations ER Studio Notation with Sample data ITEM COMPONENT ItemNo ItemDescrip ComponentNo Quantity ADC8 Audio Card PCD2 1 MBD2 Motherboard PC Dual Core RAM9 4 PCQ5 PC Quad Core . . .   1GB RAM Chip 8

Figure 4-18 Mapping a unary M:N relationship (a) Bill-of-materials relationships (M:N) (b) ITEM and COMPONENT relations