ZEIT2301- Database Design Normalisation School of Engineering and Information Technology Dr Kathryn Merrick Bldg 16, Rm 212 (Thursdays and Fridays.

Slides:



Advertisements
Similar presentations
Normalisation to 3NF Database Systems Lecture 11 Natasha Alechina.
Advertisements

The Relational Model System Development Life Cycle Normalisation
Chapter 8 Normal Forms Based on Functional Dependencies Deborah Costa Oct 18, 2007.
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.
The Relational Database Model:
1 NORMALISATION. 2 Introduction Overview Objectives Intro. to Subject Why we normalise 1, 2 & 3 NF Normalisation Process Example Summary.
Chapter 5 Normalization Transparencies © Pearson Education Limited 1995, 2005.
July 14, 2015ICS 424: recap1 Relational Database Design: Recap of ICS 324.
NORMALIZATION N. HARIKA (CSC).
Normalization II. Boyce–Codd Normal Form (BCNF) Based on functional dependencies that take into account all candidate keys in a relation, however BCNF.
Database Architecture The Relational Database Model.
Introduction to Schema Refinement. Different problems may arise when converting a relation into standard form They are Data redundancy Update Anomalies.
ZEIT2301 – Database Design Entity-Relationship Diagrams
© Pearson Education Limited, Chapter 2 The Relational Model Transparencies.
Relational Model Session 6 Course Name: Database System Year : 2012.
CS 405G: Introduction to Database Systems 16. Functional Dependency.
Copyright © 2012 Pearson Education, Inc. Publishing as Prentice Hall 9.1.
Lecture 12 Inst: Haya Sammaneh
ZEIT2301 Design of Information Systems SQL: Creating a Database School of Engineering and Information Technology Dr Kathryn Merrick.
Concepts and Terminology Introduction to Database.
Component 4: Introduction to Information and Computer Science Unit 6: Databases and SQL Lecture 4 This material was developed by Oregon Health & Science.
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.
Concepts of Database Management, Fifth Edition
Normalization. Learners Support Publications 2 Objectives u The purpose of normalization. u The problems associated with redundant data.
Normalization (Codd, 1972) Practical Information For Real World Database Design.
Concepts of Relational Databases. Fundamental Concepts Relational data model – A data model representing data in the form of tables Relations – A 2-dimensional.
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.
Normalisation Rules and Practical Application Geoff Leese January 2010.
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
Lecture9:Functional Dependencies and Normalization for Relational Databases Prepared by L. Nouf Almujally Ref. Chapter Lecture9 1.
10/3/2012ISC329 Isabelle Bichindaritz1 Logical Design.
Normal Forms through BCNF CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
ZEIT2301 Design of Information Systems SQL: Computing Statistics School of Engineering and Information Technology Dr Kathryn Merrick.
Chapter 13 Normalization Transparencies. 2 Chapter 13 - Objectives u Purpose of normalization. u Problems associated with redundant data. u Identification.
1 5 Normalization. 2 5 Database Design Give some body of data to be represented in a database, how do we decide on a suitable logical structure for that.
What's a Database A Database Primer Let’s discuss databases n Why they are hard n Why we need them.
CIS 210 Systems Analysis and Development Week 6 Part II Designing Databases,
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
Lecture No 14 Functional Dependencies & Normalization ( III ) Mar 04 th 2011 Database Systems.
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.
Component 4/Unit 6d Topic IV: Design a simple relational database using data modeling and normalization Description and Information Gathering Data Model.
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.
Lecture9:Functional Dependencies and Normalization for Relational Databases Ref. Chapter Lecture9 1.
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
Lecture Nine: Normalization
Dr. Mohamed Osman Hegaz1 Logical data base design (2) Normalization.
© Pearson Education Limited, Normalization Bayu Adhi Tama, M.T.I. Faculty of Computer Science University of Sriwijaya.
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 MIS335 Database Systems. Why Normalization? Optimizing database structure Removing duplications Accelerating the instructions Data integrity!
NORMALIZATION. What is Normalization  The process of effectively organizing data in a database  Two goals  To eliminate redundant data  Ensure data.
Postgresql East Philadelphia, PA Databases – A Historical Perspective.
IS6145 Database Analysis and Design Lecture 10: Normalization of Data Tables Rob Gleasure
Normalisation 1NF to 3NF Ashima Wadhwa. In This Lecture Normalisation to 3NF Data redundancy Functional dependencies Normal forms First, Second, and Third.
Lecture 4: Logical Database Design and the Relational Model 1.
Logical Design 12/10/2009GAK1. Learning Objectives How to remove features from a local conceptual model that are not compatible with the relational model.
Chapter 3 The Relational Model. Objectives u Terminology of relational model. u How tables are used to represent data. u Connection between mathematical.
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
Relational Data Model, Review Relation Tuple Attribute Domains Candidate key, primary key Key attribute, non-key attribute.
Lecture # 17 Chapter # 10 Normalization Database Systems.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
Chapter 8 Relational Database Design Topic 1: Normalization Chuan Li 1 © Pearson Education Limited 1995, 2005.
Normalization Dale-Marie Wilson, Ph.D..
Database.
Presentation transcript:

ZEIT2301- Database Design Normalisation School of Engineering and Information Technology Dr Kathryn Merrick Bldg 16, Rm 212 (Thursdays and Fridays only)

Topic 08: Database Normalisation Designing a ‘good’ relational database Normal forms First normal form Second normal form Third normal form

A Motivating Example Suppose we want to develop a database of bike statistics for a program that permits users to find out whether or not each bike can stoppie.

A file for such data might be… Harley false Harley one pax false Honda true Honda one pax true Bike description Wheelbase Centre of mass height Coefficient of friction This column contains two types of data (bike type and number of passengers) This column contains duplicate (redundant) data Data in this column is not even bike dependent Can stoppie?

Relations Relations are data tables with rows and columns Row Column

Attributes Attributes are named columns of relations Out bike example has five attributes: Bike description WheelbaseCentre of mass height Coefficient of friction Can stoppie

Domains The domain of an attribute is the set of allowable values for that attribute Attribute domains in our bike example: AttributeDomain Bike descriptionAlphanumeric: size 60; WheelbaseNumeric: range [0-5] Centre of mass heightNumeric: range [0-5] Coefficient of frictionNumeric: range [0-1] Can stoppieBoolean: one of [true, false]

Records (Tuples) A record or tuple is one row of data in a relation Our bike example has four records Bike descriptionWheelbas e Centre of mass height Coefficient of friction Can stoppie Harley false Harley one pax false Honda true Honda one pax true

Relational Databases A relational database is a collection of normalised relations Normalisation is a technique for producing a set of tables that conform to desirable redundancy and integrity constraints There are three common normal forms: First normal form Second normal form Third normal form

First Normal Form (1NF) A table is in 1NF if: The intersection of every column and record contains only one value and It has a primary key attribute that uniquely identifies every record

Keys (Revision) Superkey: a column or set of columns that uniquely identifies a record in a relation Candidate key: a superkey with the minimum number of columns Primary key: the candidate key selected for identification purposes Foreign key: a column or set of columns in one table that matches a candidate key of another table

12 Decomposition to 1NF Remove multi-valued attributes Add a primary key

The bike example in 1NF Bike name Number of riders WheelbaseCentre of mass height Coefficient of friction Can stoppie Harley false Harley false Honda true Honda true Bike name* Number of riders* WheelbaseCentre of mass height Coefficient of friction Can stoppie Harley false Harley false Honda true Honda true

Second Normal Form (2NF) A table is in 2NF if: It is in 1NF and The values in each non-primary-key column depend on value in all primary key columns (ie: not a subset of the primary keys)

15 Decomposition for 2NF Remove non-primary key attributes that are not fully functionally dependant on the primary key Place them in a new relation with the part of the primary key on which they are functionally dependant (i.e. their determinant) Consider replacing compound primary keys with non- compound keys

16 Full Functional Dependency Examine the non key attributes in “creditRecord”: address employer interestRate limit From the FDs given, the attributes address, employer and interestRate are not dependent on the whole primary key The attribute limit is fully functionally dependent on the primary key creditRecord(customer, creditCard, address, employer, limit, interestRate)

The bike example in 2NF Bike name*Wheelbase Harley1.588 Honda1.458 Scenario ID* Bike name Number of riders Centre of mass height Coefficient of friction Can stoppie 1Harley false 2Harley false 3Honda true 4Honda true

Third Normal Form (3NF) A table is in 3NF if: It is in 1NF and It is in 2NF and The values in each non-primary-key column depend on values in only the primary key columns

19 Transitive Functional Dependency Cnsider a relation with attributes A, B, and C. If B is functional dependent on A (A  B), and C is functional dependent on B (B  C), then C is transitively dependent on A. A  B, B  C If any non-key attribute is transitively dependent on the primary key, the relation is not in 3NF.

The bike example in 3NF Bike name* Number of riders* Centre of mass height Harley Harley Honda Honda Road conditions* Coefficient of friction Icy0.1 Wet0.5 Dry0.9 Scenario ID* Bike name Number of riders Road conditions Can stoppie 1Harley1Dryfalse 2Harley2Dryfalse 3Honda1Drytrue 4Honda2Drytrue Bike name* Wheelbase Harley1.588 Honda1.458

21 “Codd’s Law of Normalization” Thou shalt depend upon the key (1NF), the whole key (2NF), and nothing but the key (3NF)!

22 Normalization Exercise: 1NF? member No namehomeCityhobbysportsportHQ 833ChangSydneycoin collectingNetballLyneham 834JonesCanberradrag racing, video games AFLEssendon 927WickenPerthvideo gamesAFLEssendon 968ApartiDarwincoin collecting, drag racing RugbyRandwick 972NixonPerthtiddlywinksNetballLyneham member(memberNo, name, homeCity, hobby, sport, sportHQ)

Session 1, Normalization Exercise: 1NF membe r No namehome CitysportsportHQ 833ChangSydneyNetballLyneham 834JonesCanberraAFLEssendon 927WickenPerthAFLEssendon 968ApartiDarwinRugbyRandwick 972NixonPerthNetballLyneham member(memberNo, name, homeCity,hobby, sport, sportHQ) memberHobby(memberNo, hobby) member No hobby 833coin collecting 834drag racing 834video games 927video games 968coin collecting 968drag racing 972tiddlywinks Both tables are in 1NF: All attributes are single valued and depend on PK

24 Normalization Exercise: 2NF? membe r No namehome CitysportsportHQ 833ChangSydneyNetballLyneham 834JonesCanberraAFLEssendon 927WickenPerthAFLEssendon 968ApartiDarwinRugbyRandwick 972NixonPerthNetballLyneham member(memberNo, name, homeCity, sport, sportHQ) FDs: memberNo  name, homeCity, sport, sportHQ sport  sportHQ Do all non-key attributes depend on the whole PK?

Session 1, Normalization Exercise: 2NF member No namehome CitysportsportHQ 833ChangSydneyNetballLyneham 834JonesCanberraAFLEssendon 927WickenPerthAFLEssendon 968ApartiDarwinRugbyRandwick 972NixonPerthNetballLyneham member(memberNo, name, homeCity, sport, sportHQ) FDs: memberNo  name, homeCity, sport, sportHQ sport  sportHQ Do all non-key attributes depend on the whole PK? PK is not composite. All attributes depend on the PK. Table is in 2NF

26 Normalization Exercise: 3NF? membe r No namehome CitysportsportHQ 833ChangSydneyNetballLyneham 834JonesCanberraAFLEssendon 927WickenPerthAFLEssendon 968ApartiDarwinRugbyRandwick 972NixonPerthNetballLyneham member(memberNo, name, homeCity, sport, sportHQ) FDs: memberNo  name, homeCity, sport, sportHQ sport  sportHQ Are there any transitive dependencies between non- key attributes?

Session 1, Normalization Exercise: 3NF member No namehome Citysport 833ChangSydneyNetball 834JonesCanberraAFL 927WickenPerthAFL 968ApartiDarwinRugby 972NixonPerthNetball member(memberNo, name, homeCity, sport) sport(sport, sportHQ) FDs: memberNo  name, homeCity, sport, sportHQ sport  sportHQ Decompose based on transitive dependencies. NB. Maintain a link between tables sportsportHQ NetballLyneham AFLEssendon RugbyRandwick

Session 1, Normalization Exercise: 3NF sport(sport, sportHQ) FDs: memberNo  name, homeCity, sport, sportHQ sport  sportHQ sport table: 1NF (all attributes single valued and dependant on PK) 2NF (attribute depends on the whole key) 3NF (no transitive dependencies between non- key attributes) sportsportHQ NetballLyneham AFLEssendon RugbyRandwick

29 Normalization Exercise: 2NF 3NF memberHobby(memberNo, hobby) member Nohobby 833coin collecting 834drag racing 834video games 927video games 968coin collecting 968drag racing 972tiddlywinks memberHobby table: 1NF: All attributes are single- valued 2NF: Table is all key. No non- key attributes so table is in 2NF 3NF: No non-key attributes so no transitive dependencies between them!

Summary After today’s lecture you should be able to: Design a normalised relational database in First normal form Second normal form Third normal form