Modelling Techniques - Normalisation Description and exemplification of normalisation.Description and exemplification of normalisation. Creation of un-normalised.

Slides:



Advertisements
Similar presentations
Copyright: ©2005 by Elsevier Inc. All rights reserved. 1 Author: Graeme C. Simsion and Graham C. Witt Chapter 3 The Entity-Relationship Approach.
Advertisements

Normalisation.
Designing MS-Access Tables
Chapter 5 Normalization of Database Tables
RJP/RDA 1 /93 Relational Data Analysis (RDA) RDA organises all the system’s data items into a set of well NORMALISED relations. These should avoid: 1.
Relational Database Systems Higher Information Systems.
Normalisation Ensuring data integrity in database design 1.
Normalization of Database Tables
Normalisation “A formal technique for analysing relations based on their primary key and functional dependencies.” [Codd]. Process – Analyse each relation.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
CS263:Revision on Normalisation
The Relational Database Model:
Normalization of Database Tables
Chapter 5 Normalization Transparencies © Pearson Education Limited 1995, 2005.
Relational Data Analysis II. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.
Chapter 5 Normalization of Database Tables
Project and Data Management Software
LOGICAL DATABASE DESIGN
Introduction to Schema Refinement. Different problems may arise when converting a relation into standard form They are Data redundancy Update Anomalies.
Normalization. Introduction Badly structured tables, that contains redundant data, may suffer from Update anomalies : Insertions Deletions Modification.
Normalization of Tables “Between two evils, choose neither; between two goods, choose both.” Tryon Edwards.
Lecture 12 Inst: Haya Sammaneh
CREATE THE DIFFERENCE Normalisation (special thanks to Janet Francis for this presentation)
Concepts and Terminology Introduction to Database.
Relational databases and third normal form As always click on speaker notes under view when executing to get more information!
Chapter 6 Normalization 正規化. 6-2 In This Chapter You Will Learn:  更動異常  How tables that contain redundant data can suffer from update anomalies ( 更動異常.
CBAD2103 Data Analysis and Modeling. Chapter 7 Conceptual Design Methodology.
Avoiding Database Anomalies
Database Systems: Design, Implementation, and Management Tenth Edition
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
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
1 DATABASE SYSTEMS DESIGN IMPLEMENTATION AND MANAGEMENT INTERNATIONAL EDITION ROB CORONEL CROCKETT Chapter 7 Normalisation.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
SALINI SUDESH. Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of.
Normalization Transparencies
CORE 2: Information systems and Databases NORMALISING DATABASES.
Overview of the Systems Analysis and Design cycle Description of the stages of the systems analysis and design life cycle as applied to the development.
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
Handling Many to Many Relationships. 2 Handling Many:Many Relationships Aims: To explain why M:M relationships cannot be implemented in relational database.
Lecture 5 Normalization. Objectives The purpose of normalization. How normalization can be used when designing a relational database. The potential problems.
Chapter 10 Normalization Pearson Education © 2009.
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.
Programming Logic and Design Fourth Edition, Comprehensive Chapter 16 Using Relational Databases.
Lecture Nine: Normalization
9/23/2012ISC329 Isabelle Bichindaritz1 Normalization.
Case Study 1 Normalisation - the easy way? Read Case Study 1 produce a 3NF. show consideration of UNF, 1NF and 2NF.
Normalization. 2 u Main objective in developing a logical data model for relational database systems is to create an accurate representation of the data,
Normalization Example. Database Systems, 8 th Edition 2 Database Tables and Normalization Normalization –Process for evaluating and correcting table structures.
Lection №4 Development of the Relational Databases.
Normalisation RELATIONAL DATABASES.  Last week we looked at elements of designing a database and the generation of an ERD  As part of the design and.
Topic 3 – Data Modeling Techniques Unit 1 – Database Analysis and Design Advanced Higher Information Systems St Kentigern’s Academy.
11/10/2009GAK1 Normalization. 11/10/2009GAK2 Learning Objectives Definition of normalization and its purpose in database design Types of normal forms.
Description and exemplification use of a Data Dictionary. A data dictionary is a catalogue of all data items in a system. The data dictionary stores details.
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).
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.
Logical Database Design and Relational Data Model Muhammad Nasir
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Lecture # 17 Chapter # 10 Normalization Database Systems.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
NORMALISATION OF DATABASES. WHAT IS NORMALISATION? Normalisation is used because Databases need to avoid have redundant data, which makes it inefficient.
Dr Gordon Russell, Napier University Normalisation 1 - V2.0 1 Normalisation 1 Unit 3.1.
Entity relationship diagrams
Chapter 4.1 V3.0 Napier University Dr Gordon Russell
Chapter 14 Normalization.
Chapter 17 Designing Databases
Normalisation 1 Unit 3.1 Dr Gordon Russell, Napier University
Presentation transcript:

Modelling Techniques - Normalisation Description and exemplification of normalisation.Description and exemplification of normalisation. Creation of un-normalised form (UNF) from complex source document(s).Creation of un-normalised form (UNF) from complex source document(s). First normal form:First normal form: –identifying repeating groups, dealing with repeating groups, problems with first normal form (1NF). Second normal form:Second normal form: –functional dependency, problems with second normal form (2NF). Third normal form:Third normal form: –transitive dependency.

Normalisation Normalisation aims to remove data redundancy by applying rules in a series of stages, splitting tables within the existing database system and creating relationships between them to ensure that the structure of the database is efficient and data can be accurately manipulated. The structure produced by the normalisation process will be efficient and allow data to be easily updated and maintained. The structure will contain a number of related tables. Each table will have a number of properties: – –The order of the rows in not significant. The rows do not have to be in any particular order and the order may be changed without loss of information. – –The order of the columns is not significant. The columns of a table may be interchanged without loss of information. – –Each row/column intersection contains only one value. – –Each row of the table must be capable of being uniquely identified by a single attribute or a combination of attributes. This attribute or combination of attributes is referred to as the primary key. The primary key cannot contain a null value. – –Each table is linked to at least one other table in the system. The attribute used to link one table to another is called the foreign key.

Normalisation Normalisation is a complex mathematical process. To fully understand it, you must first understand the terms repeating group and functional dependency. A repeating group is defined to be a set of two or more multi-valued attributes. For example: – –a single book title may have several authors – –a single pupil may sit exams in several different subjects A functional dependency occurs when one attribute - or combination of attributes - in a relation uniquely determines another attribute.

Normalisation When carried out correctly, the normalisation process identifies an efficient structure for the entities in the database system. Normalisation ensures that: – –all redundant data has been removed from the entities This means that all duplicated values have been removed and the database system will require less memory. As a result, any processing carried out on the data will be more efficient. – –all data anomalies have been removed This means that whenever the data is to be updated, it only needs to be updated once. New details can be added to and deleted from individual tables without affecting details held in other tables. This ensures that the data is easy to maintain. All entities created as a result of applying the normalisation process are said to demonstrate entity integrity. Foreign keys are used to relate one entity to another. Whenever this happens, the normalised data must demonstrate referential integrity

Working example – car rental client_nbrclient_nbr client_nameclient_name client_addressclient_address client_telephoneclient_telephone client_faxclient_fax contact_personcontact_person shipment_nbrshipment_nbr insurance_refinsurance_ref fromfrom toto datedate timetime van_regvan_reg modelmodel makemake capacitycapacity fuel_typefuel_type rental_costrental_cost Look through the list and identify any potential primary keysLook through the list and identify any potential primary keys –client_nbr –shipment_nbr –insurance_ref –van_reg Sometimes when the list comes from more than 1 source document there will be repeating attributes. If there are any they must be removed!Sometimes when the list comes from more than 1 source document there will be repeating attributes. If there are any they must be removed! Choose 1 PK and turn into UNF.Choose 1 PK and turn into UNF.

UNF The most important step in creating UNF is analysing the source document or documents (there may be more than one) in order to determine the attributes that are held in the system. If there is more than one source document, it is best to deal with each document separately. Once the attributes in each document have been fully normalised, any links between the sets of normalised tables can be easily identified. This process of linking sets of normalised entities to create a single normalised system is called consolidation. Creating UNF for a single document – –analyse the details held on the source document carefully – –write down a single list of all attributes that appear in the source document – –identify any attributes that can be calculated using other values in the system – –identify the primary key of the un-normalised attributes by underlining it – –identify any repeating groups of data – –name each UNF entity

Working example – car rental CLIENT(client_nbrCLIENT(client_nbr client_nameclient_name client_addressclient_address client_telephoneclient_telephone client_faxclient_fax contact_personcontact_person shipment_nbr shipment_nbr insurance_ref insurance_ref from from to to date date time time van_reg van_reg model model make make capacity capacity fuel_type fuel_type rental_cost) rental_cost) This is unnormalised form (UNF).This is unnormalised form (UNF). We have selected our first Entity – client.We have selected our first Entity – client. We can see the attributes that will belong to client and the attributes that would be repeating because they belong in other entities. E.g the client may have more than 1 van take a shipment to them, the client may have more than 1 shipment. These are repeating values.We can see the attributes that will belong to client and the attributes that would be repeating because they belong in other entities. E.g the client may have more than 1 van take a shipment to them, the client may have more than 1 shipment. These are repeating values.

1NF The most important step in creating 1NF is the removal of repeating groups of data. By removing repeating groups of data to form separate entities, we reduce data duplication and therefore make the database more efficient. We also remove any values that can be calculated since this again reduces the storage that is necessary and improves the efficiency of the database.

1NF Creating 1NF from UNF – –Write out list of attributes in main entity leaving behind any repeating group(s). Also leave out any attributes that can be calculated. – –Create a separate list of attributes for each repeating group. If one set of attributes repeats inside another set, take the outer set of repeating attributes out from the main entity before removing the inner set of repeating attributes. – –Identify a primary key of each new entity by underlining it. – –Copy the primary key of any outer repeating group into the inner repeating group and asterisk it to indicate that this is the foreign key link to the outer repeating group. – –Take a copy of the primary key of the main entity into each new entity and asterisk it to indicate that it is also a foreign key. – –Decide whether or not this foreign key is needed to form a unique value for the primary key of each new entity. – –Name each 1NF entity.

Working example – car rental CLIENT(client_nbrCLIENT(client_nbr client_nameclient_nameclient_addressclient_telephone client_faxclient_fax contact_person)contact_person) REMOVAL(REMOVAL( shipment_nbrshipment_nbr insurance_refinsurance_ref fromfrom toto datedate van_regvan_reg modelmodel makemake capacitycapacity fuel_typefuel_type rental_costrental_cost *client_nbr) To choose the primary key of removal ask the question – Is there an attribute that is unique for each client? The answer is yes – shipment_nbr. So this is our PK.To choose the primary key of removal ask the question – Is there an attribute that is unique for each client? The answer is yes – shipment_nbr. So this is our PK. A foreign key must be added to the removal so that a relationship can be created so we add client_nbr as a foreign key.A foreign key must be added to the removal so that a relationship can be created so we add client_nbr as a foreign key. This is 1 st Normal Form (1NF).This is 1 st Normal Form (1NF).

2NF The most important step in creating 2NF is the removal of non-key attributes that only depend on part of the primary key. This means that 2NF is only of concern when the primary key of an entity is a compound primary key - in other words, it is composed of two or more attributes. Where the primary key is a single attribute, the entity is already in second normal form. Attributes that depend on part of the primary key are said to have a partial dependency on the primary key. The aim of 2NF is to create entities where every non-key attribute is fully dependent on the primary key of the entity.

2NF Creating 2NF from 1NF – –Copy out any entities with a single primary key. These entities are already in 2NF – –In entities with a compound primary key, identify any attributes that depend on part of the compound primary. – –Write out the attributes in the entity with the compound primary key, leaving behind any attributes that have a partial dependency. – –Mark the part of the primary key that the caused the partial dependency with an asterisk. This is a foreign key link to the new entity you are about to create. – –Create a new entity by copying the part of the compound primary key that is responsible for the partial dependency. This becomes the primary key of the new entity. – –Add the non-key attributes that have a partial dependency to the new entity. – –Name each 2NF entity.

Working example – car rental CLIENT(client_nbrCLIENT(client_nbr client_nameclient_nameclient_addressclient_telephone client_faxclient_faxcontact_person) Shipment(shipment_nbrShipment(shipment_nbrinsurance_ref) Removal (*shipment_nbrRemoval (*shipment_nbrfromtodatetimevan_regmodel makemakecapacityfuel_typerental_cost *client_nbr) Client is in 2NF because the attributes all rely on client_nbr and no other key.Client is in 2NF because the attributes all rely on client_nbr and no other key. Next we look at the attributes in removal:Next we look at the attributes in removal: –According to Removal we have a compound key (made up of >1 PK). –Is there any attribute(s) in removal that does not use the compound key only 1 of the keys (either the PK or FK)? Yes insurance_ref. We do not need to know the client_nbr to get the insurance_ref we only need the shipment_nbr. So we give shipment_nbr and insurance_ref its’ own entity.So we give shipment_nbr and insurance_ref its’ own entity. This is 2NF.This is 2NF.

3NF The most important step in creating 3NF is the removal of non-key attributes that depend on other non-key attributes. Non-key attributes that depend on other non-key attributes are said to have transitive dependency. Creating 3NF from 2NF – –Write out a list of all attributes in any entities that have one or less non-key attributes. These are already in 3NF. – –Examine other entities carefully in order to identify transitive dependencies. – –Write out the attributes in any entity found to have a transitive dependency, leaving behind any non-key attributes that have a transitive dependency. – –Mark the non-key attribute that is responsible for the transitive dependency with an asterisk to indicate a foreign key. – –Copy this attribute and create new entity. Underline the attribute to indicate that the attribute is the primary key. – –Add the non-attributes involved in the transitive dependency into this new entity. – –Name each 3NF entity.

Working example – car rental CLIENT(client_nbrCLIENT(client_nbr client_nameclient_nameclient_addressclient_telephoneclient_faxcontact_person) Shipment(shipment_nbrShipment(shipment_nbrinsurance_ref) Removal (*shipment_nbrRemoval (*shipment_nbrfromto datedate timetime *van_reg*van_reg *client_nbr) VAN (van_regVAN (van_reg modelmodel makemake capacitycapacity fuel_typefuel_type rental_cost)rental_cost) A relation is in 3NF if all the columns depend on the primary key and not on any other column:A relation is in 3NF if all the columns depend on the primary key and not on any other column: –Client is in 3NF –Shipment is in 3NF –Removal is not because the details of a van are repeated everytime the van is used for removal but from, to, date and time are a history and depend on the client and shipment. –The details for van rely on the van_reg, not on shipment_nbr and client_nbr. So the entity VAN is created and the van attributes stored here. –Still one problem we need to know which van is used for which removal so van_reg is in removal as a FK. This is 3NF.This is 3NF.