©G. Millbery 2005Relational and Online Database Management SystemsSlide 1 Module 5.3.4 Relational and Online Database Management Systems Normalisation.

Slides:



Advertisements
Similar presentations
Normalisation.
Advertisements

Topic Database Normalisation S McKeever Advanced Databases 1.
Normalisation Ensuring data integrity in database design 1.
Athabasca University Under Development for COMP 200 Gary Novokowsky
Chapter 5 Normalization of Database Tables
Project and Data Management Software
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 5 Normalization of Database Tables.
Bad DB Design Duplicate of data Duplicate of data Updating Updating Deleting Deleting.
Database Design Concepts Info 1408 Lecture 2 An Introduction to Data Storage.
Database Normalization CP3410 Daryle Niedermayer, I.S.P., PMP.
Normalization. Introduction Badly structured tables, that contains redundant data, may suffer from Update anomalies : Insertions Deletions Modification.
Week 6 Lecture Normalization
The Teacher Computing Database Design CP4 Revision.
DATABASE MANAGEMENT SYSTEMS BASIC CONCEPTS 1. What is a database? A database is a collection of data which can be used: alone, or alone, or combined /
DATABASE MANAGEMENT SYSTEMS BASIC CONCEPTS 1. What is a database? A database is a collection of data which can be used: alone, or alone, or combined /
Modelling Techniques - Normalisation Description and exemplification of normalisation.Description and exemplification of normalisation. Creation of un-normalised.
CREATE THE DIFFERENCE Normalisation (special thanks to Janet Francis for this presentation)
DAY 15: ACCESS CHAPTER 2 Larry Reaves October 7,
Unit 4 Normalisationand Relational Database Management Systems.
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!
MIS 301 Information Systems in Organizations Dave Salisbury ( )
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Completing the Model Common Problems in Database Design.
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
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Normalisation Mia’s Sandwich Shop The Process Explained.
1 DATABASE SYSTEMS DESIGN IMPLEMENTATION AND MANAGEMENT INTERNATIONAL EDITION ROB CORONEL CROCKETT Chapter 7 Normalisation.
Module III: The Normal Forms. Edgar F. Codd first proposed the process of normalization and what came to be known as the 1st normal form. The database.
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.
SALINI SUDESH. Primarily a tool to validate and improve a logical design so that it satisfies certain constraints that avoid unnecessary duplication of.
CORE 2: Information systems and Databases NORMALISING DATABASES.
MS Access: Creating Relational Databases Instructor: Vicki Weidler Assistant: Joaquin Obieta.
1 n 1 n 1 1 n n Schema for part of a business application relational database.
Introduction to Databases Trisha Cummings. What is a database? A database is a tool for collecting and organizing information. Databases can store information.
Unit 4 Normalisationand Relational Database Management Systems.
M1G Introduction to Database Development 4. Improving the database design.
Handling Many to Many Relationships. 2 Handling Many:Many Relationships Aims: To explain why M:M relationships cannot be implemented in relational database.
Chapter 10 Normalization Pearson Education © 2009.
Normalization Is the gradual and sequential process of efficiently organizing data in a database that follows the rules listed in the previous slide –
Normalization of Database Tables
MIS 301 Information Systems in Organizations Dave Salisbury ( )
Flat Files Relational Databases
Understand Relational Database Management Systems Software Development Fundamentals LESSON 6.1.
Sample Table Standard Notation Entity name in uppercase
NORMALIZATION: ‘1NF’ The general rule: ‘’Any field which can have many, must have its own table’’ By Sam Beaumont.
Normalisation 1NF to 3NF Ashima Wadhwa. In This Lecture Normalisation to 3NF Data redundancy Functional dependencies Normal forms First, Second, and Third.
Databases Flat Files & Relational Databases. Learning Objectives Describe flat files and databases. Explain the advantages that using a relational database.
Normalization. Overview Earliest  formalized database design technique and at one time was the starting point for logical database design. Today  is.
IMS 4212: Normalization 1 Dr. Lawrence West, Management Dept., University of Central Florida Normalization—Topics Functional Dependency.
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
What Is Normalization  In relational database design, the process of organizing data to minimize redundancy  Usually involves dividing a database into.
MS Access. Most A2 projects use MS Access Has sufficient depth to support a significant project. Relational Databases. Fairly easy to develop a good user.
Starter Draw a mind map for topic 6 Databases. Objectives Revise topic CG3.6 Databases using various activities and ensure that topics covered are understood.
Normalisation FORM RULES 1NF 2NF 3NF. What is normalisation of data? The process of Normalisation organises your database to: Reduce or minimise redundant.
( ) 1 Chapter # 8 How Data is stored DATABASE.
Database Normalization. What is Normalization Normalization allows us to organize data so that it: Normalization allows us to organize data so that it:
NORMALISATION OF DATABASES. WHAT IS NORMALISATION? Normalisation is used because Databases need to avoid have redundant data, which makes it inefficient.
©G. Millbery 2003File and Database ConceptsSlide 1 Module File and Database Concepts.
Lesson 10 Databases.
Database, tables and normal forms
Databases Chapter 16.
Relational and Online Database Management Systems Normalisation
Database Normalization
Normalization Referential Integrity
Entity relationship diagrams
Relational Database Model
Lesson Objectives Aims You should know about: 1.3.2:
Presentation transcript:

©G. Millbery 2005Relational and Online Database Management SystemsSlide 1 Module Relational and Online Database Management Systems Normalisation

©G. Millbery 2005Relational and Online Database Management SystemsSlide 2 First Normal Form (1NF)  A table is in first normal form if all the data values are atomic values  In English, this means that there can only be one value per attribute The following table records managers of shoe shops. One manager can be a manager of more than one shop ManagerShop ShawGloucester, Bristol JonesTrafalgar SmithAshford, Canterbury GregBrighton, Hove This is not in 1NF because each attribute does not contain a single value. For example, Shaw is manager of Gloucester and Bristol. To be in 1NF these values need to be separated

©G. Millbery 2005Relational and Online Database Management SystemsSlide 3 First Normal Form (Cont.)  This is not in 1NF because the values are not atomic ManagerShop ShawGloucester, Bristol JonesTrafalgar SmithAshford, Canterbury GregBrighton, Hove  This is in 1NF because each cell has only 1 value ManagerShop ShawGloucester ShawBristol JonesTrafalgar SmithCanterbury SmithAshford GregBrighton GregHove

©G. Millbery 2005Relational and Online Database Management SystemsSlide 4 First Normal Form - Difficulties  Terminology differences: Atomic Indivisible Scalar »These all refer to a single value per attribute  Attributes to be careful of include: Address – e.g 24 The Grange, Oxford. OX4 6JP is not scalar Telephone – e.g is not scalar (code and number) Atomic does not only refer to the data, but to the use of data. Just because you can split data does not means that you should. Telephone should only be split if you need to sort by code for example  Official Definition: At the end of 1NF you end up with a table. In order to be a table it must have a primary key. This is officially correct and it may be necessary to add a field to give a primary key

©G. Millbery 2005Relational and Online Database Management SystemsSlide 5 Terminology: Primary Key  A primary key is a unique value which allows each record to be identified CustomerIDFirstNameLastName 1BrianSmith 2HarryAdams 3JoeJones 4HarrySmith  FirstName or LastName cannot be primary keys as they contain duplicate data. CustomerID uniquely identifies a row and is therefore suitable

©G. Millbery 2005Relational and Online Database Management SystemsSlide 6 Terminology: Primary Key (Cont.)  Sometimes there is no single field appropriate as a primary key. In these circumstances, it is possible to select two fields which, when taken together create a unique value: OrderNoItemNoEmployeeNoCustomerNoItemNameQuantity Nut Bolt Washer Bolt Washer4 There are no unique fields, so the Primary Key is best suited by OrderNo and ItemNo taken together

©G. Millbery 2005Relational and Online Database Management SystemsSlide 7 Terminology: Functional Dependence  Functional Dependency If you know the length, height and width of a room, you can calculate its volume: »Volume = width x height x length Volume is functionally dependent on the length, height and width Consider the following database, which holds orders. Each order is entered by a specific employee (only one employee is allowed to enter an order)

©G. Millbery 2005Relational and Online Database Management SystemsSlide 8 Terminology: Functional Dependency OrderNoItemNoEmployeeNoCustomerIDItemNameQuantity Nut Bolt Washer Bolt Washer4 EmployeeNo is functionally dependent on OrderNo OrderNo functionally determines EmployeeNo OrderNo is the determinant The relationship is only one way

©G. Millbery 2005Relational and Online Database Management SystemsSlide 9 Terminology: Functional Dependency  Functional Dependency – More examples A table containing PupilName and PupilID »PupilName is functionally dependent on PupilID PupilIDPupilName 34Smith 65Sams 87Hodd 654Smith  If you know the PupilID you can find any PupilName, but if you only have the name, it is not always possible to find the PupilID

©G. Millbery 2005Relational and Online Database Management SystemsSlide 10 Second Normal Form (2NF)  To be in 2NF a table must: Be in 1NF (obviously) Have all non key fields fully functionally dependant on the primary key  In English: A non key field is one that is not part of the primary key It means that you need to use the primary key to determine the value of the other fields in the table »If you can find the value of other fields without using the primary key, you should remove that field from the table and place it in a separate table

©G. Millbery 2005Relational and Online Database Management SystemsSlide 11 Second Normal Form  This table is not in 2NF The primary key is OrderNo and ItemNo (combined) The quantity is functionally dependant on the Primary Key »The ItemName is functionally dependant on the ItemNo not the primary key »The CustomerID is functionally dependant on the OrderNo, not the Primary Key »The EmployeeNo is functionally dependant on the OrderNo, not the primary key OrderNo*ItemNo*EmployeeNoCustomerIDItemNam e Quantity Bolt Washer Nut Bolt4

©G. Millbery 2005Relational and Online Database Management SystemsSlide 12 Second Normal Form (Cont.)  We need to remove ItemName, CustomerID and EmployeeNo from the table – this involves setting up new tables OrderNo*ItemNo*EmployeeNoCustomerIDItemNameQuantity Bolt Washer Nut Bolt4

©G. Millbery 2005Relational and Online Database Management SystemsSlide 13 Second Normal Form (Cont.)  EmployeeNo and CustomerNo are functionally dependant on the OrderNo, therefore they are suited for a new table: Orders OrderNo* EmployeeNo CustomerNo  The Quantity is functionally dependant on both the OrderNo and the ItemNo, therefore they have a new table: OrderSpec OrderNo* ItemNo* Quantity  We are left with the ItemName. This is functionally dependent on the item number only, therefore a new table is required: Stock ItemNo* ItemName

©G. Millbery 2005Relational and Online Database Management SystemsSlide 14 Second Normal Form (Cont.)  Do not be afraid to create new tables as appropriate but make sure that you are not breaking tables down for the sake of doing so. It should be appropriate and have advantages  Make sure that each table you create is in both 1NF and 2NF as appropriate  Ensure the original table can be rebuilt from the data contained in the new table

©G. Millbery 2005Relational and Online Database Management SystemsSlide 15 Second Normal Form  A slightly different approach: Each relation should only contain information about a single entity. If it contains information about more than one entity, then the table needs to be broken down For example: »HOUSE(HouseName, Street, Town, City, Postcode, CityPopulation) The CityPopulation is a separate entity to the house details, so it needs to be removed to a separate table To create a separate table, remove the attribute and a copy of the attribute on which it is dependent. The copy becomes the link between the two tables »HOUSE(HouseName, Street, Town, City, Postcode) »CITY(City,CityPopulation)

©G. Millbery 2005Relational and Online Database Management SystemsSlide 16 Third Normal Form (3NF)  To be in 3NF a table must: Be in second (and therefore also first) normal form Have all non key fields non transitively dependent on the primary key  In English: Fields which do not form part of the primary key must always be solely dependent on the primary key and not on anything else, such as another non key field Aside: it is usually difficult to create a table which is not in 3NF – usually you will jump straight from 1NF to 3NF!

©G. Millbery 2005Relational and Online Database Management SystemsSlide 17 Third Normal Form (Cont.)  In the following example, the company keeps data on its employees. Each employee is allocated a city where they work and each city is given a CityID. Their salary is dependent on the type of job they do. Initially check the table below to ensure it is in 2NF before continuing EmployeeNoLastNameFirstNameCityCityIDTypeSalary 1TaylorSarahCanterburyCBManager£22,000 2JonesSamLondonLNSales Person£15,000 3SmithSallyBirminghamBMAdmin Assistant£13,500

©G. Millbery 2005Relational and Online Database Management SystemsSlide 18 Third Normal Form (Cont.)  CityID is dependent on City  Salary is dependent on Type  Therefore this table is not in 3NF EmployeeNoLastNameFirstNameCityCityIDTypeSalary 1TaylorSarahCanterburyCBManager£22,000 2JonesSamLondonLNSales Person£15,000 3SmithSallyBirminghamBMAdmin Assistant£13,500

©G. Millbery 2005Relational and Online Database Management SystemsSlide 19 Third Normal Form (Cont.)  Remove City from the table and create a new cities table  Remove Salary from the table and create a job type table Staff EmployeeID* LastName FirstName CityID Type Cities CityID* City JobTypes TypeID* Salary

©G. Millbery 2005Relational and Online Database Management SystemsSlide 20 Advantages of Normalisation  More efficient database structure Better understanding of your data Easier to see how the data fits together  More flexible database structure Allows the data to be used for a variety of purposes Data is independent of interface and use  Easier to maintain database structure Changing, adding and removing data structures is easier with a relational model than any other model  Avoids redundant fields And redundant records which reduced storage space and cost of hard disk drives