Normalization. Normalization. Normalization. Data Redundancy



Similar documents
Normalization. Purpose of normalization Data redundancy Update anomalies Functional dependency Process of normalization

DATABASE NORMALIZATION

DBMS. Normalization. Module Title?

Lecture 2 Normalization

Normalization in Database Design

DATABASE DESIGN: NORMALIZATION NOTE & EXERCISES (Up to 3NF)

Bridge from Entity Relationship modeling to creating SQL databases, tables, & relations

An Algorithmic Approach to Database Normalization

Normalization of Database

COSC344 Database Theory and Applications. Lecture 9 Normalisation. COSC344 Lecture 9 1

A. TRUE-FALSE: GROUP 2 PRACTICE EXAMPLES FOR THE REVIEW QUIZ:

Normalization. Functional Dependence. Normalization. Normalization. GIS Applications. Spring 2011

7.1 The Information system

Database Design Methodologies

DATABASE SYSTEMS. Chapter 7 Normalisation

Normalisation 6 TABLE OF CONTENTS LEARNING OUTCOMES

Normalisation to 3NF. Database Systems Lecture 11 Natasha Alechina

Database Design and Normalization

Functional Dependency and Normalization for Relational Databases

CS 377 Database Systems. Database Design Theory and Normalization. Li Xiong Department of Mathematics and Computer Science Emory University

Schema Refinement, Functional Dependencies, Normalization

Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases

DATABASE DESIGN: Normalization Exercises & Answers

Chapter 10. Functional Dependencies and Normalization for Relational Databases

Theory of Relational Database Design and Normalization

Functional Dependencies and Finding a Minimal Cover

Chapter 5: FUNCTIONAL DEPENDENCIES AND NORMALIZATION FOR RELATIONAL DATABASES

Fundamentals of Database System

MCQs~Databases~Relational Model and Normalization

Normalization of database model. Pazmany Peter Catholic University 2005 Zoltan Fodroczi

Design of Relational Database Schemas

Part 6. Normalization

Normalization. CIS 3730 Designing and Managing Data. J.G. Zheng Fall 2010

Chapter 10. Functional Dependencies and Normalization for Relational Databases. Copyright 2007 Ramez Elmasri and Shamkant B.

Introduction to normalization. Introduction to normalization

Gamified Approach to Database Normalization

Chapter 9: Normalization

Chapter 6. Database Tables & Normalization. The Need for Normalization. Database Tables & Normalization

Theory of Relational Database Design and Normalization

BCA. Database Management System

14 Databases. Source: Foundations of Computer Science Cengage Learning. Objectives After studying this chapter, the student should be able to:

Chapter 10 Functional Dependencies and Normalization for Relational Databases

Normal forms and normalization

Database Design and Normal Forms

Announcements. SQL is hot! Facebook. Goal. Database Design Process. IT420: Database Management and Organization. Normalization (Chapter 3)

Database Management System

Normalization in OODB Design

LOGICAL DATABASE DESIGN

CS143 Notes: Normalization Theory

Week 11: Normal Forms. Logical Database Design. Normal Forms and Normalization. Examples of Redundancy

Topic 5.1: Database Tables and Normalization

Determination of the normalization level of database schemas through equivalence classes of attributes

Chapter 5: Logical Database Design and the Relational Model Part 2: Normalization. Introduction to Normalization. Normal Forms.

RELATIONAL DATABASE DESIGN

Databases -Normalization III. (N Spadaccini 2010 and W Liu 2012) Databases - Normalization III 1 / 31

Database Design. Marta Jakubowska-Sobczak IT/ADC based on slides prepared by Paula Figueiredo, IT/DB

If it's in the 2nd NF and there are no non-key fields that depend on attributes in the table other than the Primary Key.

CSCI-GA Database Systems Lecture 7: Schema Refinement and Normalization

RDBNorma: - A semi-automated tool for relational database schema normalization up to third normal form.

Database Normalization. Mohua Sarkar, Ph.D Software Engineer California Pacific Medical Center

Database Systems Concepts, Languages and Architectures

C# Cname Ccity.. P1# Date1 Qnt1 P2# Date2 P9# Date9 1 Codd London Martin Paris Deen London

Functional Dependencies and Normalization

Normalisation. Why normalise? To improve (simplify) database design in order to. Avoid update problems Avoid redundancy Simplify update operations

Relational Database Design Theory

The process of database development. Logical model: relational DBMS. Relation

Relational Database Design

Functional Dependencies

Schema Refinement and Normalization

Normalization. CIS 331: Introduction to Database Systems

normalisation Goals: Suppose we have a db scheme: is it good? define precise notions of the qualities of a relational database scheme

Normalization. Normalization. First goal: to eliminate redundant data. for example, don t storing the same data in more than one table

Module 5: Normalization of database tables

Normalization. Reduces the liklihood of anomolies

Relational Database Design: FD s & BCNF

DATABASE MANAGEMENT SYSTEMS. Question Bank:

Database Design and the Reality of Normalisation

How To Write A Diagram

Jordan University of Science & Technology Computer Science Department CS 728: Advanced Database Systems Midterm Exam First 2009/2010

RELATIONAL DATABASE DESIGN. Basic Concepts

Introduction to Database Systems. Normalization

Schema Design and Normal Forms Sid Name Level Rating Wage Hours

Database Design and Normalization

COMPUTING PRACTICES ASlMPLE GUIDE TO FIVE NORMAL FORMS IN RELATIONAL DATABASE THEORY

Database Management Systems 2015

2. Basic Relational Data Model

SQL Server. 1. What is RDBMS?

Quiz 3: Database Systems I Instructor: Hassan Khosravi Spring 2012 CMPT 354

Introduction Decomposition Simple Synthesis Bernstein Synthesis and Beyond. 6. Normalization. Stéphane Bressan. January 28, 2015

Database Design and Implementation

Lecture Notes on Database Normalization

6.830 Lecture PS1 Due Next Time (Tuesday!) Lab 1 Out today start early! Relational Model Continued, and Schema Design and Normalization

Chapter 7: Relational Database Design

Relational Data Analysis I

Introduction to Computing. Lectured by: Dr. Pham Tran Vu

Normalisation and Data Storage Devices

Boyce-Codd Normal Form

Teaching Database Modeling and Design: Areas of Confusion and Helpful Hints

Transcription:

Normalization Normalization o Main objective in developing a logical data model for relational database systems is to create an accurate representation of the data, its relationships, and constraints. o To achieve this objective, we must identify a suitable set of relations => The Normalization Technique o Developed by E.F. Codd (1972). Normalization - 1 Normalization - 2 Normalization o Often performed as a series of tests on a relation to determine whether it satisfies or violates the requirements of a given normal form. o 4 most commonly used normal forms are first (1NF), second (2NF), third (3NF) and Boyce-Codd (BCNF) normal forms. Data Redundancy o Major aim of relational database design is to group attributes into relations to minimize data redundancy and reduce file storage space required by base relations. o Based on functional dependencies among the attributes of a relation. o A relation can be normalized to a specific form to prevent the possible occurrence of update anomalies. Normalization - 3 Normalization - 4

Data Redundancy Update Anomalies o Relations that contain redundant information may potentially suffer from update anomalies. o Staff_Branch relation has redundant data; the details of a branch are repeated for every member of staff. o Types of update anomalies include Insertion Deletion (eg. in the Staff_Branch relation, for a particular branch, removal of the last member of staff => lost of branch information) Modification Normalization - 5 Normalization - 6 Functional Dependency Functional Dependency: o Main concept associated with normalization. Functional Dependency Diagrammatic representation: o Functional Dependency Describes the relationship between attributes in a relation. For example, if A and B are attributes of relation R, B is functionally dependent on A (denoted A -> B), if each value of A in R is associated with exactly one value of B in R. Normalization - 7 Normalization - 8

Functional Dependency 3 Types of Functional Dependencies Full Dependency o In a relation, the attribute(s) B is fully functional dependent on A if B is functionally dependent on A, but not on any proper subset of A. Partial Dependency o If there is some attribute that can be removed from A and the dependency still holds. Eg. Staff_No, Sname -> Branch_No Normalization - 9 Normalization - 10 3 Types of Functional Dependencies Transitive Dependency o In a relation, if attribute(s) A->B and B->C, then C is transitively dependent on A via B (provided that A is not functionally dependent on B or C) Eg. Staff_No->Branch_No and Branch_No->BAddress The Process of Normalization o Normalization: Formal technique for analyzing a relation based on its primary key and the functional dependencies between the attributes of that relation. o Often executed as a series of steps. Each step corresponds to a specific normal form, which has known properties. o As normalization proceeds, the relations become progressively more restricted (stronger) in format and also less vulnerable to update anomalies. Normalization - 11 Normalization - 12

Relationship Between Normal Forms Unnormalized Normal Form o Unnormalized Normal Form (UNF) A table that contains one or more repeating groups. To create an unnormalized table Transform the data from the information source (e.g. form) into table format with columns and rows. Normalization - 13 Normalization - 14 Example - A Report Example - UNF Normalization - 15 Normalization - 16

First Normal Form 1NF - A relation in which the intersection of each row and column contains one and only one value. Converting from UNF to 1NF: o Select attribute(s) to act as the key. o Identify the repeating group(s) in the unnormalized table which repeats for the key attribute(s). o Remove the repeating group by Entering data into empty columns of rows which contain the repeating data. Or by Placing the repeating data along with a copy of the original key attribute(s) into a separate relation. Normalization - 17 Example - Normalization UNF to 1NF Normalization - 18 Example - UNF to 1NF (Alternative) Second Normal Form Based on the concept of full functional dependency. A 2NF relation is in 1NF and every non-primary-key attribute is fully functionally dependent on the primary key. Converting from 1NF to 2NF: o Identify the primary key for the 1NF relation. o Identify the functional dependencies in the relation. Normalization - 19 o If partial dependencies exist on the primary key remove them by placing then in a new relation along with a copy of their determinant. Normalization - 20

FDs for Customer_Rental Relation Customer_Rental to 2NF Relations Primary key: Customer_No + Property_No Full Functional Dependency: (Customer_No+Property_No)->(RentStart, RentFinish) Partial Dependency: (Customer_No+Property_No)->Cname (Customer_No+Property_No)->(Paddress, Rent, Owner_No, Oname) Normalization - 21 Normalization - 22 Third Normal Form (3NF) Property_Owner to 3NF Relations Based on the concept of transitive dependency. A relation that is in 1NF and 2NF and in which no non-primary-key attribute is transitively dependent on the primary key. Converting from 2NF to 3NF: o Identify the primary key in the 2NF relation. Transitive Dependency: (Customer_No+Property_No)->Owner_No Owner_No ->OName o Identify functional dependencies in the relation. o If transitive dependencies exist on the primary key remove them by placing them in a new relation along with a copy of their dominant. Normalization - 23 Normalization - 24

Process of Decomposition Summary of 3NF Relations Normalization - 25 Normalization - 26 Boyce-Codd Normal Form (BCNF) o Based on functional dependencies that takes into account all candidate keys in a relation. o For a relation with only one candidate key, 3NF and BCNF are equivalent. o A relation is in BCNF, if and only if every determinant is a candidate key. o Violation of BCNF may occur in a relation that contains 2 (or more) composite keys which overlap and share at least 1 attribute 3NF to BCNF o Identify all candidate keys in the relation. o Identify all functional dependencies in the relation. o If functional dependencies exists in the relation where their determinants are not candidate keys for the relation, remove the functional dependencies by placing them in a new relation along with a copy of their determinant. Normalization - 27 Normalization - 28

Example - 3NF to BCNF Relations Example - 3NF to BCNF Relations Everyday a staff is allocated a room only. Staff may share rooms. Clients maybe interviewed again. (Client_No, Interview_Date) -> (Interview_Time, Staff_No, Room_No) (Staff_No, Interview_Date, Interview_Time) -> Client_No (Room_No, Interview_date, Interview_Time) -> Staff_No, Client_No (Staff_No, Interview_Date) -> Room_No Normalization - 29 Normalization - 30 The Process of Normalization up to BCNF Example UNF Remove repeating groups 1NF Remove partial dependencies 2NF Remove transitive dependencies 3NF Remove remaining anomalies from functional dependencies BCNF Normalization - 31 Normalization - 32

Example - UNF to 1NF Relation Example - 1NF to 2NF 1NF: Property_Inspection (Property_No, IDate, ITime, Paddress, Comments, Staff_No, Sname, Car_Reg) Full Functional Dependency: (Property_No+IDate)->(ITime, Comments, Staff_No, Sname, Car_Reg) Partial Dependency: (Property_No+IDate)->(PAddress) => 2NF: Prop (Property_No, Paddress) Prop_Inspection (Property_No, IDate, ITime, Comments, Staff_No, Sname, Car_Reg) Normalization - 33 Normalization - 34 Example - 2NF to 3NF Transitive Dependency in Prop_Inspect: (Property_No+IDate) -> Staff_No Staff_No -> Sname => 3NF: Staff (Staff_No, Sname) Prop_Inspection (Property_No, IDate, ITime, Comments, Staff_No, Car_Reg) Example - 3NF to BCNF Prop (Property_No,Paddress) Staff (Staff_No, Sname) Prop_Inspection (Property_No, IDate, ITime, Comments, Staff_No, Car_Reg) Prop and Staff are already in BCNF. FDs of Prop_Inspect: o (Property_No, IDate)->(ITime, Comments, Staff_No, Car_Reg) o (Staff_No, Idate) -> Car_Reg o (Car_Reg, Idate, ITime) -> (Property_No, Comments, Staff_No) o (Staff_No, Idate, ITime) -> (Property_No, Comments) Normalization - 35 Normalization - 36

Example BCNF Process of Decomposition Prop (Property_No,Paddress) Staff (Staff_No, Sname) Inspection (Property_No, IDate, ITime, Comments, Staff_No) Staff_Car (Staff_No, IDate, Car_Reg) Normalization - 37 Normalization - 38