1 Week 4: Normalisation: Redundant data becomes inconsistent data; therefore … “The key, the whole key, and nothing but the key,so help me, Codd”

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

Author: Graeme C. Simsion and Graham C. Witt Chapter 4 Subtypes & Supertypes.
Database Design: Normalization J.G. Zheng June 29 th 2005 DB Chapter 4.
0 - 0.
Addition Facts
Fourth normal form: 4NF 1. 2 Normal forms desirable forms for relations in DB design eliminate redundancies avoid update anomalies enforce integrity constraints.
1 Term 2, 2004, Lecture 3, NormalisationMarian Ursu, Department of Computing, Goldsmiths College Normalisation 5.
Functional dependencies 1. 2 Outline motivation: update anomalies cause: not expressed constraints on data (FDs) functional dependencies (FDs) definitions.
Relational data integrity
Dependency preservation, 3NF revisited and BCNF
Normal forms - 1NF, 2NF and 3NF
1 Term 2, 2004, Lecture 2, Normalisation - IntroductionMarian Ursu, Department of Computing, Goldsmiths College Normalisation Introduction.
1 Database Design Issues, Part I Hugh Darwen CS252.HACD: Fundamentals of Relational Databases Section.
Report Card P Only 4 files are exported in SAMS, but there are at least 7 tables could be exported in WebSAMS. Report Card P contains 4 functions: Extract,
Information Systems Today: Managing in the Digital World
Chapter 5 Normalization of Database Tables
Normalization of Database Tables
Relational Terminology. Normalization A method where data items are grouped together to better accommodate business changes Provides a method for representing.
Functional Dependencies and Normalization for Relational Databases
Addition 1’s to 20.
Test B, 100 Subtraction Facts
Week 1.
 Definition  Components  Advantages  Limitations Contents  Definition Definition  Normal Forms Normal Forms  First Normal Form First Normal Form.
Normalisation to 3NF Database Systems Lecture 11 Natasha Alechina.
Athabasca University Under Development for COMP 200 Gary Novokowsky
Chapter 8 Normalization. © 2001 The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill/Irwin Outline Modification anomalies Functional dependencies.
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.
McGraw-Hill/Irwin Copyright © 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 7 Normalization of Relational Tables.
7-1 Normalization - Outline  Modification anomalies  Functional dependencies  Major normal forms  Practical concerns.
Why Normalization? To Reduce Redundancy to 1.avoid modification, insertion, deletion anomolies 2.save space Goal: One Fact in One Place.
July 14, 2015ICS 424: recap1 Relational Database Design: Recap of ICS 324.
NORMALIZATION N. HARIKA (CSC).
Department of Computer Science and Engineering, HKUST Slide 1 Finding All the Keys Computationally, finding all the keys can be done by exhaustive search:
7 Copyright © 2006, Oracle. All rights reserved. Normalization of Relational Tables (Part I)
Daniel AdinugrohoDatabase Programming 1 DATABASE PROGRAMMING Lecture on 29 – 04 – 2005.
Chapter 5 Normalization of Database Tables
Week 6 Lecture Normalization
Lecture 12 Inst: Haya Sammaneh
CREATE THE DIFFERENCE Normalisation (special thanks to Janet Francis for this presentation)
Concepts and Terminology Introduction to Database.
IT420: Database Management and Organization Normalization 31 January 2006 Adina Crăiniceanu
Chapter 7 Normalization. Outline Modification anomalies Functional dependencies Major normal forms Relationship independence Practical concerns.
Objectives of Normalization Develop a good description of the data, its relationships and constraints Produce a stable set of relations that Is a faithful.
Chapter 7 Normalization. McGraw-Hill/Irwin © 2004 The McGraw-Hill Companies, Inc. All rights reserved. Outline Modification anomalies Functional dependencies.
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
CORE 2: Information systems and Databases NORMALISING DATABASES.
Normalization Well structured relations and anomalies Normalization First normal form (1NF) Functional dependence Partial functional dependency Second.
Lecture No 14 Functional Dependencies & Normalization ( III ) Mar 04 th 2011 Database Systems.
ITN Table Normalization1 ITN 170 MySQL Database Programming Lecture 3 :Database Analysis and Design (III) Normalization.
Database Design – Lecture 8
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.
Understand Relational Database Management Systems Software Development Fundamentals LESSON 6.1.
Postgresql East Philadelphia, PA Databases – A Historical Perspective.
Normalisation 1NF to 3NF Ashima Wadhwa. In This Lecture Normalisation to 3NF Data redundancy Functional dependencies Normal forms First, Second, and Third.
FEN Introduction to the database field: The development process Seminar: Introduction to relational databases Development process: Analyse.
NormalisationNormalisation Normalization is the technique of organizing data elements into records. Normalization is the technique of organizing data elements.
Week 4 Lecture Part 1 of 3 Normalization of Database Tables Samuel ConnSamuel Conn, Asst. Professor.
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.
7 Copyright © 2006, Oracle. All rights reserved. Normalization of Relational Tables (Part II)
Lecture # 17 Chapter # 10 Normalization Database Systems.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
Revised: 2 April 2004 Fred Swartz
Normalization Karolina muszyńska
Normalization By Jason Park Fall 2005 CS157A.
* 07/16/96 Normalization 2/16/2019 *.
Normalization By Jason Park Fall 2005 CS157A.
Review of Week 3 Relation Transforming ERD into Relations
Presentation transcript:

1 Week 4: Normalisation: Redundant data becomes inconsistent data; therefore … “The key, the whole key, and nothing but the key,so help me, Codd”

2 BoyGirl Database, Version 0 NOTE: Not a good design! Because one girl can have many boys ….. we are storing redundant mobile data about Bonnie. “Redundant data becomes inconsistent data”

3 A Better BoyGirl Database Eliminated redundant data about Bonnie Two tables with a One-to-Many relationship … … linked by a Foreign Key Foreign key Primary key

4 The Menace of Redundant Data Redundant data becomes inconsistent data Insert, modify, and delete more data than desired Strive for one fact in one place  More technically, strive for 3NF or BCNF (more later)

5 Big University Table – What’s redundant here? StdSSNStdClassOfferNoOffYearGradeCourseNoCrsDesc S1JUNO C1DB S1JUNO C2VB S2JUNO C3OO S2JUNO C2VB StdSSN  OfferNo  CourseNo  StdSSN, OfferNo  StdCity, StdClass OffTerm, OffYear, CourseNo CrsDesc EnrGrade Forgotten what these American University terms mean???? See next slide … Solution is to split the single table into two or more Tables. Like we did with BoyGirl.

6 Big University Table – Forgotten these American terms ???? StdSSNStdClassOfferNoOffYearGradeCourseNoCrsDesc StdSSN – student number (student social security number?) StdClass – Freshman, Sophomore, Junior, Senior OfferNo – e.g , Autumn 2007 Grade – A student’s grade point average a the start of semester CourseNo – e.g or … Americans say “course” for “subject” CrsDec – course description Primary Key Attributes OffYear CourseNo Offering CourseNo CrsDesc Course OfferNo

7 X  Y “X (functionally) determines Y” For each X value, there is at most one Y value “Normalisation” is the process of splitting tables to remove redundancies Functional Dependencies (FDs) x y f (x) = 2x

8 FD’s in Data Prove non-existence (but not existence) by looking at data Two rows that have the same X value but a different Y value Understand business rules (or common sense) StdSSNStdClassOfferNoOffYearGradeCourseNoCrsDesc S1JUNO C1DB S1JUNO C2VB S2JUNO C3OO S2JUNO C2VB

9 Toward First Normal Form (1NF) Normalisation step by step StdSSNStdClassOfferNoOffYearGradeCourseNoCrsDesc S1JUNO C1DB S1JUNO C2VB S2JUNO C3OO S2JUNO C2VB Step 1: Identification of superkeys. According to the previous FD diagram, we know that StdSSN, OfferNo and CourseNo form a “superkey”

10 StdSS N StdClas s OfferN o OffYea r Grad e CourseN o CrsDes c S1JUNO C1DB S1JUNO C2VB S2JUNO C3OO S2JUNO C2VB Step 2: Determining primary key (minimal superkey). If we analyze our superkey we can conclude that CourseNo is not contributing to the uniqueness of our superkey, therefore we can take it out of the key. First Normal Form (1NF)

11 Second Normal Form (2NF) Every non-key column depends on a whole key, not part of a key Violations  Part of key  non-key  Violations only for combined keys “combined”  “composite”

12 2NF Example (problem) Violations of 2NF form in the 1NF big university database table  StdSSN  StdCity, StdClass  OfferNo  OffTerm, OffYear, CourseNo, CrsDesc StdSSNStdClassOfferNoOffYearGradeCourseNoCrsDesc S1JUNO C1DB S1JUNO C2VB S2JUNO C3OO S2JUNO C2VB

13 2NF Example (solution) Splitting the table  UnivTable0 (StdSSN*, OfferNo*, EnrGrade)  UnivTable1 (StdSSN, StdCity, StdClass)  UnivTable2 (OfferNo, OffTerm, OffYear, CourseNo, CrsDesc) Where …  Underlining means “primary key”  Asterisk means foreign key

14 To get to Third Normal Form (3NF) We need to ensure that … Every non-key column depends only on a key not on non-key columns Violations: Non-key  Non-key  OfferNo  CourseNo, CourseNo  CrsDesc then OfferNo  CrsDesc

15 3NF Example One violation in UnivTable2  CourseNo  CrsDesc Splitting the table  UnivTable2-1 (OfferNo, OffTerm, OffYear, CourseNo*)  UnivTable2-2 (CourseNo, CrsDesc)

16 BCNF A special case not covered by 3NF  Where two things can be used as substitute primary keys for each other E.g. staff number, tax file number, address

17 BCNF Example StdSSNOfferNoEnrGrade UnivTable4 (Mannino’s example page ) Convert from 3NF to BCNF by placing the redundant keys in a table by themselves and only using one of them in other tables: UnivTable4-1 (StdSSN*, OfferNo, EnrGrade) UnivTable4-2 (StdSSN, )

18 Role of Normalisation Normalisation and drawing ERDS are complimentary ways of designing databases. Strive to reach at least 3NF, hopefully BCNF. There are even higher normal forms, 4NF, 5NF, etc, but we don’t talk about them in this course.  They are almost never an issue in real work databases. May reverse engineer an ERD

19 Today’s Lab Exercise (this slide not part of today’s lecture handout) Familiarisation with next week’s lab exam database. Download the lab exam database into your PostgreSQL account. See URL on page 2 of handout. Attempt the sample questions on page 5 of handout. Answers on page 6.