Chapter 4 Normalization of Database Tables. 2 Database Tables and Normalization Table is basic building block in database design Table is basic building.

Slides:



Advertisements
Similar presentations
Normalization of Database Tables
Advertisements

Chapter 5 Normalization of Database Tables
Database Tables and Normalization
5 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Normalization of Database Tables
Chapter 5 Normalization of Database Tables
Chapter 5 Normalization of Database Tables
Normalization of Database Tables
September 24, R McFadyen1 The objective of normalization is sometimes stated “to create relations where every dependency is on the primary.
DBS201: Introduction to Normalization
1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Chapter 5 Normalization of Database Tables
Normalization of Database Tables Special adaptation for INFS-3200
Normalization of Database Tables
Need for Normalization
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Normalization of Database Tables
4 Chapter 4 Normalization Hachim Haddouti. 4 Hachim Haddouti, CH4, see also Rob & Coronel 2 In this chapter, you will learn: What normalization is and.
Normalization of Database Tables
Normalization of Database Tables
Database Systems: Design, Implementation, and Management Tenth Edition
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.
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.
5 Chapter 5 Normalization of Database Tables Example Database Systems: Design, Implementation, and Management, Rob and Coronel Special adaptation for INFS-3200.
NORMALIZATION N. HARIKA (CSC).
Chapter 5 Normalization of Database Tables
FUNCTIONAL DEPENDENCIES
Week 6 Lecture Normalization
Lecture 12 Inst: Haya Sammaneh
Text & Original Presentations
ITEC 3220M Using and Designing Database Systems Instructor: Prof. Z. Yang Course Website: 3220m.htm
Avoiding Database Anomalies
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.
1 DATABASE SYSTEMS DESIGN IMPLEMENTATION AND MANAGEMENT INTERNATIONAL EDITION ROB CORONEL CROCKETT Chapter 7 Normalisation.
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.
Database Design – Lecture 8
Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management Peter Rob & Carlos Coronel.
Database Principles: Fundamentals of Design, Implementation, and Management Ninth Edition Chapter 6 Normalization of Database Tables Carlos Coronel, Steven.
Normalization of Database Tables
E-R Modeling: Table Normalization. Normalization of DB Tables Normalization ► Process for evaluating and correcting table structures determines the optimal.
9/23/2012ISC329 Isabelle Bichindaritz1 Normalization.
Normalization Example. Database Systems, 8 th Edition 2 Database Tables and Normalization Normalization –Process for evaluating and correcting table structures.
ITEC 3220A Using and Designing Database Systems Instructor: Gordon Turpin Course Website: Office: CSEB3020.
Entity Relationship Model: E-R Modeling 1 Database Design.
3 Spring Chapter Normalization of Database Tables.
Database Systems, 8 th Edition Improving the Design Table structures cleaned up to eliminate initial partial and transitive dependencies Normalization.
11/10/2009GAK1 Normalization. 11/10/2009GAK2 Learning Objectives Definition of normalization and its purpose in database design Types of normal forms.
Week 4 Lecture Part 1 of 3 Normalization of Database Tables Samuel ConnSamuel Conn, Asst. Professor.
5 1 Normalization of Database Tables. 5 2 Database Tables and Normalization Normalization –Process for evaluating and correcting table structures to minimize.
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Normalizing Database Designs. 2 Objectives In this chapter, students will learn: –What normalization is and what role it plays in the database design.
Normalization.
Chapter 5: Relational Database Design
Chapter 4: Relational Database Design
Functional Dependencies
Normalization of Database Tables PRESENTED BY TANVEERA AKHTER FOR BCA 2ND YEAR dated:15/09/2015 DEPT. OF COMPUTER SCIENCE.
Chapter 6 Normalization of Database Tables
CSCI 2141 – Intro to Database Systems
Normalization A337.
Normalization of Database Tables Uploaded by: mysoftbooks.ml
Normalization of DB relations examples Fall 2015
Review of Week 3 Relation Transforming ERD into Relations
Presentation transcript:

Chapter 4 Normalization of Database Tables

2 Database Tables and Normalization Table is basic building block in database design Table is basic building block in database design Table’s structure is of great interest Table’s structure is of great interest Two cases: Two cases: possible poor table structures in good database design possible poor table structures in good database design Modify existing database with existing poor table structure Modify existing database with existing poor table structure Normalization can help recognize a poor table and convert to good tables with good structure Normalization can help recognize a poor table and convert to good tables with good structure

3 Database Tables and Normalization Normalization is process for assigning attributes to entities Normalization is process for assigning attributes to entities Reduces data redundancies Reduces data redundancies Expending entities Expending entities Helps eliminate data anomalies Helps eliminate data anomalies Produces controlled redundancies to link tables Produces controlled redundancies to link tables Cost more processing efforts Cost more processing efforts Series steps called normal forms Series steps called normal forms

4 Database Tables and Normalization Normalization stages Normalization stages 1NF - First normal form 1NF - First normal form 2NF - Second normal form 2NF - Second normal form 3NF - Third normal form 3NF - Third normal form 4NF - Fourth normal form 4NF - Fourth normal form Better in dependency Worse in performance (I/O) Business Bioinformatics Statistical data

5 Database Tables and Normalization Example: construction company Example: construction company Building projects Building projects Project number Project number Project name Project name Employees assigned Employees assigned … Employee Employee Employee number Employee number Employee name Employee name Job classification Job classification

6 Table 4.1 should be here.

7 Figure 4.1 Observations PRO_NUM intended to be primary key, but it contains null values. PRO_NUM intended to be primary key, but it contains null values. Table entries invite data inconsistencies Table entries invite data inconsistencies

8 Figure 4.1 Observations Table displays data redundancies which yield the following anomalies Table displays data redundancies which yield the following anomalies Update Update Modifying JOB_CLASS Modifying JOB_CLASS Insertion Insertion New employee must be assigned project (phantom project) New employee must be assigned project (phantom project) Deletion Deletion If employee deleted, other vital data lost If employee deleted, other vital data lost

9 Figure 4.2 is insert here. Repeating group (any project can have a group of data entries) which should not to be appeared in relational table

10 Data Organization: 1NF Figure 4.3 PK

11 Conversion to 1NF Repeating groups must be eliminated Repeating groups must be eliminated Proper primary key developed Proper primary key developed Uniquely identifies attribute values (rows) Uniquely identifies attribute values (rows) Combination of PROJ_NUM and EMP_NUM Combination of PROJ_NUM and EMP_NUM

12 Conversion to 1NF Repeating groups must be eliminated Repeating groups must be eliminated Dependencies can be identified Dependencies can be identified A particular relationship between two attributes. For a given relation, attribute B is functionally dependent on attribute A if, for every valid value of A, that value of A uniquely determines the value of B. A particular relationship between two attributes. For a given relation, attribute B is functionally dependent on attribute A if, for every valid value of A, that value of A uniquely determines the value of B. A functional dependency exists when the value of one thing is fully determined by another. For example, given the relation EMP(empNo, empName, sal), attribute empName is functionally dependant on attribute empNo. If we know empNo, we also know the empName. A functional dependency exists when the value of one thing is fully determined by another. For example, given the relation EMP(empNo, empName, sal), attribute empName is functionally dependant on attribute empNo. If we know empNo, we also know the empName.

13 Desirable dependencies based on primary key Less desirable dependencies Partial based on part of composite primary key Transitive one nonprime attribute depends on another nonprime attribute

14 Dependency Diagram (1NF) Figure 4.4 Above: Desired Dependencies Below: Less Desired Dependencies Composite primary key

15 PROJ_NUM,EMP_NUM  PROJ_NAME, EMP_NAME, JOB_CLASS,CHG_HOUR, HOURS PROJ_NUM  PROJ_NAME DESIRED DEPENDENCIES EMP_NUM  EMP_NAME, JOB_CLASS, CHG_HOUR PARTIAL DEPENDENCIES JOB_CLASS -> CHG_HOUR TRANSITIVE DEPENDENCIES

16 1NF Summarized All key attributes defined All key attributes defined No repeating groups in table No repeating groups in table All attributes dependent on All attributes dependent on primary key primary key

17 Conversion to 2NF Start with 1NF format: Start with 1NF format: Write each key component on separate line Write each key component on separate line Write original key on last line Write original key on last line Each component is new table Each component is new table Write dependent attributes after each key Write dependent attributes after each key PROJECT (PROJ_NUM, PROJ_NAME) EMPLOYEE (EMP_NUM, EMP_NAME, JOB_CLASS, CHG_HOUR) ASSIGN (PROJ_NUM, EMP_NUM, HOURS)

18 2NF Conversion Results Figure 4.5

19 2NF Summarized In 1NF In 1NF Includes no partial dependencies Includes no partial dependencies No attribute dependent on a portion of primary key No attribute dependent on a portion of primary key Still possible to exhibit transitive dependency Still possible to exhibit transitive dependency Attributes may be functionally dependent on nonkey attributes Attributes may be functionally dependent on nonkey attributes

20 Conversion to 3NF Create separate table(s) to eliminate transitive functional dependencies Create separate table(s) to eliminate transitive functional dependencies PROJECT (PROJ_NUM, PROJ_NAME) ASSIGN (PROJ_NUM, EMP_NUM, HOURS) EMPLOYEE (EMP_NUM, EMP_NAME, JOB_CLASS) JOB (JOB_CLASS, CHG_HOUR)

21 3NF Summarized In 2NF In 2NF Contains no transitive dependencies Contains no transitive dependencies

22 Additional DB Enhancements Figure 4.6

23

24 Boyce-Codd Normal Form (BCNF) Every determinant in the table is a candidate key Every determinant in the table is a candidate key Determinant is attribute whose value determines other values in row Determinant is attribute whose value determines other values in row 3NF table with one candidate key is already in BCNF 3NF table with one candidate key is already in BCNF

25 3NF Table Not in BCNF Figure 4.7

26 Decomposition of Table Structure to Meet BCNF Figure 4.8

27 Example: BCNF conversion

28 Decomposition into BCNF Figure 4.9

29 Normalization and Database Design Normalization should be part of the design process Normalization should be part of the design process Make sure the proposed entities meet the required normal form before the table structures are created Make sure the proposed entities meet the required normal form before the table structures are created Used to redesign or modify the existing table structures. Used to redesign or modify the existing table structures. E-R Diagram provides macro view E-R Diagram provides macro view

30 Normalization and Database Design Normalization provides micro view of entities Normalization provides micro view of entities Focuses on characteristics of specific entities Focuses on characteristics of specific entities May yield additional entities May yield additional entities Difficult to separate normalization from E-R diagramming Difficult to separate normalization from E-R diagramming Business rules must be determined Business rules must be determined

31 Normalization and Database Design Contracting company’s example: Contracting company’s example: PROJECT (PROJ_NUM, PROJ_NAME) EMPLOYEE(EMP_NUM, EMP_LNAME,EMP_FNAME,EMP_INITAL, JOB_DESCRIPTION, JOB_CHG_HOUR);

32 Initial ERD for Contracting Company Figure 4.10 Already 3NF There is a transitive dependency

33 PROJECT (PROJ_NUM, PROJ_NAME) EMPLOYEE(EMP_NUM, EMP_LNAME,EMP_FNAME,EMP_INITAL, JOB_CODE) JOB (JOB_CODE, JOB_DESCRIPTION, JOB_CHG_HOUR); Removal

34 Modified ERD for Contracting Company Figure 4.11

35 Final ERD for Contracting Company Figure 4.12 (M:N) converting to (1:M)

36 PROJECT (PROJ_NUM, PROJ_NAME, EMP_NUM) EMPLOYEE(EMP_NUM, EMP_LNAME,EMP_FNAME,EMP_INITAL, EMP_HIREDATE, JOB_CODE) JOB (JOB_CODE,, JOB_DESCRIPTION, JOB_CHG_HOUR); ASSIGN((ASSIGN_NUM, ASSIGN_DATE, ASSIGN_HOURS, ASSIGN_CHG_HOURS, ASSIGN_CHARGE, EMP_NUM, PROJ_JUM)

37

38 Denormalization Normalization is one of many database design goals Normalization is one of many database design goals Normalized table requirements Normalized table requirements Additional processing Additional processing Loss of system speed Loss of system speed

39 Denormalization Normalization purity is difficult to sustain due to conflict in: Normalization purity is difficult to sustain due to conflict in: Design efficiency Design efficiency Information requirements Information requirements Processing Processing