Database Design Concepts Lecture 19 Term 2 week 8 Worked example of normalisation.

Slides:



Advertisements
Similar presentations
Normalisation.
Advertisements

Designing MS-Access Tables
Normalisation 1 Chapter 4.1 V3.0 Napier University Dr Gordon Russell.
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
Accounting 6500 Relational Databases: Accounting Applications Introduction to Normalization.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
CS263:Revision on Normalisation
Normalisation up to 1NF Bottom-up Approach to Data Modelling.
1 NORMALISATION. 2 Introduction Overview Objectives Intro. to Subject Why we normalise 1, 2 & 3 NF Normalisation Process Example Summary.
Database Design Concepts INFO1408 Term 2 week 1 Data validation and Referential integrity.
Relational Data Analysis II. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.
Project and Data Management Software
Terms - data,information, file record, table, row, column, transaction, concurrency Concepts - data integrity, data redundancy, Type of databases – single-user,
Database Design.  Define a table for each entity  Give the table the same name as the entity  Make the primary key the same as the identifier of the.
Week 6 Lecture Normalization
Lecture 12 Inst: Haya Sammaneh
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)
Database Management System Lecture 6 The Relational Database Model – Keys, Integrity Rules.
1 Chapter 1 Overview of Database Concepts. 2 Chapter Objectives Identify the purpose of a database management system (DBMS) Distinguish a field from a.
Avoiding Database Anomalies
Normalization A technique that organizes data attributes (or fields) such that they are grouped to form stable, flexible and adaptive entities.
Module Title? DBMS Normalization. Module Title? DBMS Normalization  Normalization is the process of removing redundant data from tables in order to improve.
RDBMS Concepts/ Session 3 / 1 of 22 Objectives  In this lesson, you will learn to:  Describe data redundancy  Describe the first, second, and third.
A Normalisation Example Mark Kelly McKinnon Secondary College Vceit.com Based on work by Robert Timmer-Arends.
Normalisation Mia’s Sandwich Shop The Process Explained.
Concepts of Relational Databases. Fundamental Concepts Relational data model – A data model representing data in the form of tables Relations – A 2-dimensional.
資料庫正規化 Database Normalization 取材自 AIS, 6 th edition By Gelinas et al.
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.
IMS 4212: Normalization 1 Dr. Lawrence West, Management Dept., University of Central Florida Normalization—Topics Functional Dependency.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
Customer Order Order Number Date Cust ID Last Name First Name State Amount Tax Rate Product 1 ID Product 1 Description Product 1 Quantity Product 2 ID.
What's a Database A Database Primer Let’s discuss databases n Why they are hard n Why we need them.
Chapter 1Introduction to Oracle9i: SQL1 Chapter 1 Overview of Database Concepts.
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.
ITN Table Normalization1 ITN 170 MySQL Database Programming Lecture 3 :Database Analysis and Design (III) Normalization.
Btec National - Advanced Databases 1 Advanced Databases Entity Relationship Diagrams.
In this session, you will learn to: Describe data redundancy Describe the first, second, and third normal forms Describe the Boyce-Codd Normal Form Appreciate.
Database Design Normalisation. Last Session Looked at: –What databases were –Where they are used –How they are used.
Chapter 56 Relational Database Design Compiled by Eddie Moorcroft.
BSA206 Database Management Systems Lecture 2: Introduction to Oracle / Overview of Database Concepts.
Mr C Johnston ICT Teacher
Producing a Mail Merged Letter Step 1 Create an Access database for Names and Addresses you can use the ‘Customers’ template in Group Work. Enter the necessary.
Sample Table Standard Notation Entity name in uppercase
Btec National - IT SYSTEMS ANALYSIS AND DESIGN 1 IT Systems Analysis and Design Entity Relationship Diagrams.
Databases Database Normalisation. Learning Objectives Design simple relational databases to the third normal form (3NF).
NormalisationNormalisation Normalization is the technique of organizing data elements into records. Normalization is the technique of organizing data elements.
IMS 4212: Normalization 1 Dr. Lawrence West, Management Dept., University of Central Florida Normalization—Topics Functional Dependency.
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
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.
Normalisation Unit 6: Databases. Just to recap  What is an Entity  What is an Attribute?
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.
Year 12 > 13 Applied GCE ICT Unit 7 Using Database Software.
Normalisation Worked example for an Order Remember : The data should depend upon the key, the whole key and nothing but the key.
NORMALISATION OF DATABASES. WHAT IS NORMALISATION? Normalisation is used because Databases need to avoid have redundant data, which makes it inefficient.
Relational Databases – Further Study I think we’ve covered all you need to know for GCSE about relational databases I’m not aware of any practical coursework.
Dr Gordon Russell, Napier University Normalisation 1 - V2.0 1 Normalisation 1 Unit 3.1.
Revised: 2 April 2004 Fred Swartz
Database Normalization
© 2011 Pearson Education, Inc. Publishing as Prentice Hall
Entity relationship diagrams
Chapter 4.1 V3.0 Napier University Dr Gordon Russell
Normalisation 1 Unit 3.1 Dr Gordon Russell, Napier University
Presentation transcript:

Database Design Concepts Lecture 19 Term 2 week 8 Worked example of normalisation

Objectives In this lecture we will introduce the process of normalisation. Through using a worked example we will introduce the concepts of 1 st Normal From 2 nd normal Form 3 rd Normal Form

Step by step plan to normalisation Investigate the users requirements Use documents ( there may be several)

Identify the attributes from the form List attributes Booking reference numberFlight number Customer nameDirection Customer AddressOperator PhoneArrival time Villa nameDeparture airport Addressnumber of passengers cost DestinationTotal Start date CostTotal Cost End Date

Give attributes a full name. Identify groups of data which repeat by adding brackets Add any missing attributes ( in this case weekly cost of villa) Booking reference number Customer Name Customer Address (Customer Phone) Villa name Villa Address Start Date End Date Cost of villa Weekly cost of villa A customer can have more than one phone number

These are all contained in a bracket because they will repeat as a group together. These are usually shown on a form as a table (Direction Flight number Operator Arrival Time Departure airport Number of Passengers Cost of Flight Total cost of flight) Total cost of holiday

Find a key We need to check all the attributes to identify a unique identifier This is an attribute which will uniquely identify what the table is showing. It is usually a number.There will be no other row with this value in the key field. In this case booking reference number If there is no key field you may need to add one. Name the table Booking Name any column that can have multiple values by creating a new attribute. In this case Customer phone number 2

Normally we show the table like this Booking( Bookingreferencenumber,customer name,customer address, customer phone, Customer phone2, villa name, villa address, destination, start date of holiday, end date of holiday,weekly cost of villa, villa cost for holiday,(Flight number, direction, operator, departure airport, flight time, arrival time, number of passengers,cost of flight, total cost for flight), total cost of holiday) Repeating group Added attribute Named column Table name Unique identifier

We are now ready to normalise Summary so far List all attributes from source document(s) Give all attributes their full name Create extra attributes for attributes which may have may have several values eg Phones Add any obvious missing attributes Show repeating groups in brackets Identify the unique identifier if there is one Add a unique identifier if necessary Name table- in this case booking

First normal form Remove repeating groups Identify each repeating group. In this case the group with flight number For each group Remove the attributes of the repeating group from the existing table to a new table

( Flight number, direction, operator, departure airport, flight time, arrival time, number of passengers,cost of flight, total cost for flight) Leaving Booking( Bookingreferencenumber, customer name,customer address, customer phone, Customer phone2, villa name, villa address, destination, start date of holiday, end date of holiday,weekly cost of villa, villa cost for holidaytotal cost of holiday) Booking( Bookingreferencenumber, customer name,customer address,customer phone, Customer phone2, villa name, villa address, destination, start date of holiday, end date of holiday,weekly cost of villa, villa cost for holiday,(Flight number, direction, operator, departure airport, flight time, arrival time, number of passengers,cost of flight, total cost for flight), total cost of holiday)

This becomes a new table Place the attributes in brackets As it is a new table - give it a name (bookedFlights) Add the unique identifier from the original table to the new table ( as a foreign key- Booking reference number) Identify a unique identifier for the new table-

Creating a unique identifier This could be A composite key  Made up of the foreign key and another attribute from the table. These two (or more) attributes uniquely identify any row of the table OR An entirely new attribute added to the table

In this example Flight number appears a good idea It is a number ( key fields are often numbers- but not always) However Is it possible for more than one record in the table to have the same flight number? So it is not unique However could a booking have the same flight number more than once? So Booking reference number and flight number would be unique- A composite key

Unique identifier- the whole lot Booked flights(Flight number, booking reference number, direction, operator, departure airport, flight time, arrival time, number of passengers,cost of flight, total cost for flight,) Repeat process for any other repeating groups –none in this case. Name of Table Unique identifier of original table

Second Normal Form All attributes in the table must be determined by the whole unique identifier Take each table with a composite unique identifier and check each attribute can only determined from the unique identifier- Consider what we did last week In other words is the value of the attribute associated with the value in the identifier or just one part of it

Starting with the flight table Booked Flight ( Booking reference number, Flight number, direction, operator, departure airport, flight time, arrival time, number of passengers,cost of flight, total cost for flight) Eg is direction determined by the whole key or part of it? Do I need to know the booking reference number and the flight number? The flight number only Or Booking reference number only To know the direction of the flight

Direction is determined by the flight number only Work through the attributes individually in this way remembering which part of the key they are dependant on. Draw the functional determinancy diagram

Direction Operator Departure airport Flight Time Arrival Time Number of Passengers Cost of flight Total cost of flight Determined by flight number only

Booking reference no Flight no Total cost No of passengers Direction Operator Departure Airport Flight time Arrival time Cost of flight

Remove these attributes from the table Place all attributes that are dependant on on part of the key in a table together. Give the table a name. Add a unique identifier – this will be the attribute they are dependant on. This becomes-

This will create a new table flights(flight number,direction, operator, departure airport, flight time, arrival time, cost of flight) All the attributes removed were dependant on the same attribute so are all in the same table There are no more tables with composites

The booked flight table now looks like this. BookedFlight ( Booking reference number, Flight number, number of passengers, total cost for flight) Check the names of the old table to check it is still sensible

Third normal form Remove transitive dependencies Transitive dependency is when an attribute can be determined by a non key attribute/unique identifier Identify them and the non-key attribute they are dependant on For each table ( which does not have a composite key) check for transitive dependency

Booking table Booking (Booking reference number,customer name,customer address, customer phone, customer phone2,villa name, villa address, destination, start date of holiday, end date of holiday,weekly cost of villa, villa cost for holiday,total cost of holiday) Customer address is determined by the customers name ie a customer name will have one customer address associated with it. Continue through the remaining attributes Draw the functional determinancy table

Customer nameDestination Villa name ? Customer Address- customer name Start date of holiday Booking Reference Number Customer phone Customer name End date of holiday Booking reference number Customer phone 2 Customer name Weekly cost of villa- booking reference number Villa nameVilla cost of holiday Booking reference number Villa address Villa name Total cost of holiday Booking reference number

Booking (Booking reference number,customer name,customer address, customer phone, customer phone 2,villa name, villa address, destination, start date of holiday, end date of holiday,weekly cost of villa, villa cost for holiday,total cost of holiday) 1 Remove from the table into tables for each grouping (two tables), 2. Add the attribute they are dependant on. 3. Identify a unique identifier for the new table(s) 4. Put the unique identifier in the original table ( As a foreign key) 5. Give the new table(s) a name.

Booking reference no Customer name Villa name Start date of holiday End date of holiday Villa cost of holiday Total cost of holiday Customer address Customer phone Customer phone 2 Villa address Destination Weekly cost of villa

( customer name, customer address, customer phone, customer phone2 ) Are any of these attributes unique? We could have two customers with the same Name Address Phone number None are unique so add a new attribute- Customer number as the key/unique identifier Name the table, add customer number to the original booking table

( villa name, villa address, destination,) Are any of these attributes unique? We could have two villas with the same Name Address ( unlikely but possible) None are unique so add a new attribute- Villa number as the key/unique identifier Name the table, add villa number to the original booking table

Booking (Booking reference number,customer number, villa number, start date of holiday, end date of holiday,,villa cost for holiday,total cost of holiday Customer( customer number, Customer name,customer address, customer phone, customer phone2) Villa(Villa number, villa name, villa address, destination, weekly cost of villa)

Check flights and booked flights- these have no transitive dependancies

Finally remove calculated attributes if you wish Booking (Booking reference number, customer number, villa number, start date of holiday, end date of holiday, villa cost for holiday, total cost of holiday Customer(customer number, customer name,customer address, customer phone, customer phone 2) Villa(villa number, villa name, villa address, weekly cost of villa, destination,) Booked Flight (Booking reference number, Flight number, number of passengers, total cost for flight,) flights(flight number,direction,operator, departure airport, flight time, arrival time, cost of flight)

Fully normalised Tables Booking (Booking reference number, customer number, villa number, start date of holiday, end date of holiday, villa cost for holiday) Customer(customer number, customer name,customer address, customer phone, customer phone 2) Villa(villa number, villa name, villa address, weekly cost of villa,destination,) Flight (Booking reference number, Flight number, direction, number of passengers, total cost for flight) Booked flights(flight number,operator, departure airport, flight time, arrival time, cost of flight)

Summary We have completed an example. You should be able to split tables to comply with the rules of 1 st, 2 nd and 3 rd normal form. Identify appropriate unique identifiers Ensure foreign keys are present to create links This will remove redundancy, repeating groups as well as column and row order significance. You will do some examples in the tutorials.