A Normalisation Example Mark Kelly McKinnon Secondary College Vceit.com Based on work by Robert Timmer-Arends.

Slides:



Advertisements
Similar presentations
Normalisation.
Advertisements

A Normalisation Example
Athabasca University Under Development for COMP 200 Gary Novokowsky
Jump to first page Normalization Jump to first page Topics n Why normalization is needed n What causes anomalies n What the 4 normal forms are n How.
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.
1 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 5 Database Design: Normalization.
Relational Data Analysis II. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.
Normalization A337. A337 - Reed Smith2 Structure What is a database? ◦ Tables of information  Rows are referred to as records  Columns are referred.
1 5 Concepts of Database Management, 4 th Edition, Pratt & Adamski Chapter 5 Database Design 1: Normalization.
NORMALIZATION N. HARIKA (CSC).
Introduction to Schema Refinement. Different problems may arise when converting a relation into standard form They are Data redundancy Update Anomalies.
Introduction to Schema Refinement
The Relational Database Model CST272. Return Creating the Unnormalized Table n List the fields n Select a primary key – The field (or concatenation of.
Week 6 Lecture Normalization
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
Modelling Techniques - Normalisation Description and exemplification of normalisation.Description and exemplification of normalisation. Creation of un-normalised.
Concepts and Terminology Introduction to Database.
FILE VS. DATABASES Let’s examine some basic principles about how data are stored in computer systems. – An entity is anything about which the organization.
Avoiding Database Anomalies
Normalization A technique that organizes data attributes (or fields) such that they are grouped to form stable, flexible and adaptive entities.
Bordoloi Database Design: Normalization Dr. Bijoy Bordoloi.
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, Fifth Edition
Database Management COP4540, SCS, FIU Relation Normalization (Chapter 14)
Normalization Are we Normal. Normalization Normalization is the process of converting complex data structures into simple, stable data structures It also.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
Objectives of Normalization Develop a good description of the data, its relationships and constraints Produce a stable set of relations that Is a faithful.
Normalization. We will take a look at –First Normal Form –Second Normal Form –Third Normal Form There are also –Boyce-Codd, Fourth and Fifth normal forms.
資料庫正規化 Database Normalization 取材自 AIS, 6 th edition By Gelinas et al.
Logical Database Design Relational Model. Logical Database Design Logical database design: process of transforming conceptual data model into a logical.
SALINI SUDESH. Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of.
1 CMPT 275 Phase: Design. Janice Regan, Map of design phase DESIGN HIGH LEVEL DESIGN Modularization User Interface Module Interfaces Data Persistance.
CORE 2: Information systems and Databases NORMALISING DATABASES.
Data Models and Relational Databases Chapter 2. Learning Objectives Identify primary and foreign keys for each entity and relevant relationships in the.
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.
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
1 Transforming the Data Model into Relations (Tables) and Normalisation Students.
Lecture No 14 Functional Dependencies & Normalization ( III ) Mar 04 th 2011 Database Systems.
M1G Introduction to Database Development 4. Improving the database design.
ITN Table Normalization1 ITN 170 MySQL Database Programming Lecture 3 :Database Analysis and Design (III) Normalization.
Database Design – Lecture 8
Normalization of Database Tables
Normalization Transparencies 1. ©Pearson Education 2009 Objectives How the technique of normalization is used in database design. How tables that contain.
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.
Normalization MIS335 Database Systems. Why Normalization? Optimizing database structure Removing duplications Accelerating the instructions Data integrity!
Ahsan Abdullah 1 Data Warehousing Lecture-6Normalization Virtual University of Pakistan Ahsan Abdullah Assoc. Prof. & Head Center for Agro-Informatics.
IST Database Normalization Todd Bacastow IST 210.
Normalisation 1NF to 3NF Ashima Wadhwa. In This Lecture Normalisation to 3NF Data redundancy Functional dependencies Normal forms First, Second, and Third.
Databases Database Normalisation. Learning Objectives Design simple relational databases to the third normal form (3NF).
RELATIONAL TABLE NORMALIZATION. Key Concepts Guidelines for Primary Keys Deletion anomaly Update anomaly Insertion anomaly Functional dependency Transitive.
Normalization. Overview Earliest  formalized database design technique and at one time was the starting point for logical database design. Today  is.
NormalisationNormalisation Normalization is the technique of organizing data elements into records. Normalization is the technique of organizing data elements.
Copyright © Curt Hill Schema Refinement II 2 nd NF to 3 rd NF to BCNF.
NORMALIZATION Handout - 4 DBMS. What is Normalization? The process of grouping data elements into tables in a way that simplifies retrieval, reduces data.
Logical Database Design and Relational Data Model Muhammad Nasir
SLIDE 1IS 257 – Fall 2006 Normalization Normalization theory is based on the observation that relations with certain properties are more effective.
INLS 623 – D ATABASE N ORMALIZATION Instructor: Jason Carter.
Dr Gordon Russell, Napier University Normalisation 1 - V2.0 1 Normalisation 1 Unit 3.1.
Component 2 5A-F.
INLS 623 – Database Normalization
Examples of normalization
Chapter 4.1 V3.0 Napier University Dr Gordon Russell
Examples of normalization
Database Normalisation
2. Problem Without Normalization
Normalization.
Normalisation 1 Unit 3.1 Dr Gordon Russell, Napier University
Presentation transcript:

A Normalisation Example Mark Kelly McKinnon Secondary College Vceit.com Based on work by Robert Timmer-Arends

Problem Without Normalization Updation Anomaly : To update address of a student who occurs twice or more than twice in a table, we will have to update S_Address column in all the rows, else data will become inconsistent. Insertion Anomaly : Suppose for a new admission, we have a Student id(S_id), name and address of a student but if student has not opted for any subjects yet then we have to insert NULL there, leading to Insertion Anamoly. Deletion Anomaly : If (S_id) 401 has only one subject and temporarily he drops it, when we delete that row, entire student record will be deleted along with it. S_idS_NameS_AddressSubject_opted 401AdamNoidaBio 402AlexPanipatMaths 403StuartJammuMaths 404AdamNoidaPhysics

First Normal Form (1NF) A row of data cannot contain repeating group of data i.e each column must have a unique value. Each row of data must have a unique identifier i.e Primary key. For example consider a table which is not in First normal form

Take the following table. StudentID is the primary key. Is it 1NF?

No. There are repeating groups (subject, subjectcost, grade) How can you make it 1NF?

Create new rows so each cell contains only one value But now look – is the studentID primary key still valid?

No – the studentID no longer uniquely identifies each row You now need to declare studentID and subject together to uniquely identify each row. So the new key is StudentID and Subject.

Second Normal Form (2NF) A table to be normalized to Second Normal Form there must not be any partial dependency of any column on primary key. It means that for a table that has concatenated primary key, each column in the table that is not part of the primary key must depend upon the entire concatenated key for its existence. If any column depends oly on one part of the concatenated key, then the table fails Second normal form.

So. We now have 1NF. Is it 2NF?

Studentname and address are dependent on studentID (which is part of the key) This is good. But they are not dependent on Subject (the other part of the key)

And 2NF requires… All non-key fields are dependent on the ENTIRE key (studentID + subject)

So it’s not 2NF How can we fix it?

Make new tables Make a new table for each primary key field Give each new table its own primary key Move columns from the original table to the new table that matches their primary key…

Step 1 STUDENT TABLE (key = StudentID)

Step 2 STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject)

Step 3 STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject)

Step 3 STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject)

Step 4 - relationships STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject)

Step 4 - cardinality STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) 1 Each student can only appear ONCE in the student table

Step 4 - cardinality STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) 1 1 Each subject can only appear ONCE in the subjects table

Step 4 - cardinality STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) A subject can be listed MANY times in the results table (for different students)

Step 4 - cardinality STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) A student can be listed MANY times in the results table (for different subjects)

A 2NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) SubjectCost is only dependent on the primary key, Subject

A 2NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) Grade is only dependent on the primary key (studentID + subject)

A 2NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) Name, Address are only dependent on the primary key (StudentID)

But is it 3NF? STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) So it is 2NF!

Third Normal Form (3NF) Third Normal form applies that every non- prime attribute of table must be dependent on primary key. The transitive functional dependency should be removed from the table.

A 3NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) Oh oh … What?

A 3NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) HouseName is dependent on both StudentID + HouseColour

A 3NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) Or HouseColour is dependent on both StudentID + HouseName

A 3NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) But either way, non-key fields are dependent on MORE THAN THE PRIMARY KEY (studentID)

A 3NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) And 3NF says that non-key fields must depend on nothing but the key

A 3NF check STUDENT TABLE (key = StudentID) SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) WHAT DO WE DO?

Again, carve off the offending fields SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject)

A 3NF fix SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject)

A 3NF fix SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject)

A 3NF win! SUBJECTS TABLE (key = Subject) RESULTS TABLE (key = StudentID+Subject) Or…

The Reveal Before… After… RESULTS TABLE (key = StudentID+Subject) SUBJECTS TABLE (key = Subject)