Rob Gleasure R.Gleasure@ucc.ie www.robgleasure.com IS6125 Database Analysis and Design Lecture 11: Normalization of Data Tables Rob Gleasure R.Gleasure@ucc.ie.

Slides:



Advertisements
Similar presentations
Convert ER to Relational Database Entity relation Entity relation Attributes attributes Attributes attributes Primary key primary key Primary key primary.
Advertisements

Relational Database Design Via ER Modelling
1 Logical Database Design and the Relational Model Modern Database Management.
The Relational Model System Development Life Cycle Normalisation
Systems Development Life Cycle
© 2005 by Prentice Hall 1 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 7 th Edition Jeffrey A. Hoffer, Mary B.
1 © Prentice Hall, 2002 Chapter 5: Logical Database Design and the Relational Model Modern Database Management 6 th Edition Jeffrey A. Hoffer, Mary B.
©Silberschatz, Korth and Sudarshan2.1Database System Concepts Reduction of an E-R Schema to Tables A database which conforms to an E-R diagram can be represented.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
Introduction to Schema Refinement. Different problems may arise when converting a relation into standard form They are Data redundancy Update Anomalies.
MIS 385/MBA 664 Systems Implementation with DBMS/ Database Management Dave Salisbury ( )
Concepts and Terminology Introduction to Database.
Chapter 3: Relational Model I Structure of Relational Databases Structure of Relational Databases Convert a ER Design to a Relational Database Convert.
CMPE 226 Database Systems September 16 Class Meeting Department of Computer Engineering San Jose State University Fall 2015 Instructor: Ron Mak
Normalization A technique that organizes data attributes (or fields) such that they are grouped to form stable, flexible and adaptive entities.
M Taimoor Khan Course Objectives 1) Basic Concepts 2) Tools 3) Database architecture and design 4) Flow of data (DFDs)
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.
1 Session 2 Welcome: The seventh learning sequence “ Reduction of an EER schema to tables“ Recap : In the previous learning sequence, we discussed the.
Logical Database Design (1 of 3) John Ortiz Lecture 6Logical Database Design (1)2 Introduction  The logical design is a process of refining DB schema.
11/07/2003Akbar Mokhtarani (LBNL)1 Normalization of Relational Tables Akbar Mokhtarani LBNL (HENPC group) November 7, 2003.
ICOM 5016 – Introduction to Database Systems Lecture 9 Dr. Manuel Rodriguez Department of Electrical and Computer Engineering University of Puerto Rico,
Database System Concepts, 6 th Ed. ©Silberschatz, Korth and Sudarshan Lecture-03 Introduction –Data Models Lectured by, Jesmin Akhter.
IS6145 Database Analysis and Design Lecture 6: Logical Modelling Rob Gleasure
IS6125 Database Analysis and Design Lecture 11: Normalization of Data Tables Rob Gleasure
Logical Database Design and the Relational Model.
Understand Relational Database Management Systems Software Development Fundamentals LESSON 6.1.
Logical Database Design and the Relational Model.
© 2009 Pearson Education, Inc. Publishing as Prentice Hall 1 Chapter 5 (Part a): Logical Database Design and the Relational Model Modern Database Management.
IST Database Normalization Todd Bacastow IST 210.
IS6145 Database Analysis and Design Lecture 10: Normalization of Data Tables Rob Gleasure
Mapping ER to Relational Model Each strong entity set becomes a table. Each weak entity set also becomes a table by adding primary key of owner entity.
Lecture 4: Logical Database Design and the Relational Model 1.
1 The Relational Data Model David J. Stucki. Relational Model Concepts 2 Fundamental concept: the relation  The Relational Model represents an entire.
IT 5433 LM3 Relational Data Model. Learning Objectives: List the 5 properties of relations List the properties of a candidate key, primary key and foreign.
Chapter 2: Entity-Relationship Model
Lecture 5 Supplement – ER Model & Mapping to Relational Model
IS6145 Database Analysis and Design Lecture 7: Logical Modelling
Relational Database Design by ER- and EER-to- Relational Mapping
Revised: 2 April 2004 Fred Swartz
Chapter 4 Logical Database Design and the Relational Model
SEEM3430: Information Systems Analysis and Design
Rob Gleasure IS6125 Database Analysis and Design Lecture 11: Normalization of Data Tables Rob Gleasure
Database Normalization
Chapter 5: Logical Database Design and the Relational Model
Entity-Relationship Model
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Tables and Their Characteristics
Database Design – Lecture 4
Quiz Questions Q.1 An entity set that does not have sufficient attributes to form a primary key is a (A) strong entity set. (B) weak entity set. (C) simple.
Entity-Relationship Model
Constraints in Entity-Relationship Models
Payroll Management System
Example Question–Is this relation Well Structured? Student
CMPE 226 Database Systems February 21 Class Meeting
Relational Model and ER Model: in a Nutshell
Relational Database.
Entity relationship diagrams
Database Normalization
Chapter 4.1 V3.0 Napier University Dr Gordon Russell
Chapter 5: Logical Database Design and the Relational Model
Session 2 Welcome: The seventh learning sequence
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Normalization.
CHAPTER 4: LOGICAL DATABASE DESIGN AND THE RELATIONAL MODEL
Rob Gleasure IS6145 Database Analysis and Design Lecture 9: Normalization of Data Tables Rob Gleasure
Normalisation to 3NF.
Chapter 2: Intro to Relational Model
Mapping an ERD to a Relational Database
Database.
Normalisation 1 Unit 3.1 Dr Gordon Russell, Napier University
Presentation transcript:

Rob Gleasure R.Gleasure@ucc.ie www.robgleasure.com IS6125 Database Analysis and Design Lecture 11: Normalization of Data Tables Rob Gleasure R.Gleasure@ucc.ie www.robgleasure.com

IS6125 Today’s session What did we learn from the reports? Creating tables from ERDs Normalisation

Themes to reflect on with the reports Three Vs Datafication and the Internet of Things Recording things is the first step Information asymmetry It’s bad for a market when one side knows more than the other about the quality of specific instances Privacy Data has value to a consumer Different types of data Self-reported data Trace/exhaust data Profiling data

Using tables Image from http://www.funpic.hu/en/categories/others-photo/4490_table-motorboat

A note on attribute naming In ER model, the same attribute name is allowed to appear in different entity types since they imply different roles for the attribute name – this duplication is not something we want to carry over to our tables The easiest way to do this is just to add a relation-specific prefix to the name of all attributes for that table, e.g. instead of ‘licence’ we name the attribute ‘car_licence’

Constraints Primary key Has to have three qualities Unique Irreducible Never null

ER to Table Mapping For each strong (regular) entity type Create a table Create an attribute for every attribute of the corresponding entity type. Note that: For composite attributes only their constituent atomic components are recorded Derived attributes are not recorded Choose a primary key

ER to Table Mapping (continued) Example of mapping strong entity Ch_name Ch_age …

ER to Table Mapping (continued) For each weak entity type, Create a table Create an attribute in each schema for every attribute of the corresponding entity type Add the primary key of the identifying parent entity type as attribute(s) in the table schema. The attribute(s) thus added plus the partial key of the weak entity type form the primary key of the table representing the weak entity type

ER to Table Mapping (continued) Example of mapping weak entity  FORM (strong entity)  SPECIAL NEED Fm_form_ID Fm_contact Fm_name … Sn_need Sn_Fm_form_ID Sn_Fm_contact …

ER to Relational Mapping For each relationship Identify the referencing schema (the child in the relationship) Where relationships are one-to-many, the referencing schema will be the on the ‘many’ side Where relationships are one-to-one, just pick the one that makes sense Enforce a foreign key constraint between the tables participating in the relationship type Note: The attribute will have to be optional if the relationship is zero-to-one or zero-to-many

ER to Relational Mapping Example of mapping relationship  CHILD  ROOM Ch_name Ch_Age Ch_Rm_name … Rm_name Rm_Size …

Normalization!

Inferring Functional Dependencies (The Armstrong Axioms) 1. Reflexivity: If Y is a subset of X, then X Y 2. Augmentation: If X Y, then XZ YZ 3: Transitivity: If X Y, and Y Z, then X Z

Normalisation: Orders Table Full_ Name Address Zone Order _ID Date Product_1 Cost_P1 Units_P1 Product_2 Cost_P2 Units_P2 Product_3 Cost_P3 Units_ P3 John Murphy 123 Fake St Inner-city S345 31/12/ 2014 Football $20.00 2 Gloves $53.50 1 Whistle $5.00 Mary Byrne Kildaman-fadar Rural R367 9/9/ Helmet $30.50 Anne Dunne N654 10/6/ Pants $13.75 Hat $11.00 Jim Feltz 20c Fake St D896 13/06/ $28.75 Boots $75.95 S354 1/01/ 2015 Socks $3.50 5

Normalisation: First Normal Form Name Address Zone Order _ID Date Product Cost Units John Murphy 123 Fake St Inner-city S345 31/12/ 2014 Football $20.00 2 Gloves $53.50 1 Whistle $5.00 S354 Socks $3.50 5 Mary Byrne Kildaman-fadar Rural R367 9/9/ Helmet $30.50 Anne Dunne N654 10/6/ Pants $13.75 Hat $11.00 Jim Feltz 20c Fake St D896 13/06/ $28.75 Boots $75.95

First Normal Form (continued) Name Last_ Address Zone Order _ID Date Product Cost Units John Murphy 123 Fake St Inner-city S345 31/12/ 2014 Football $20.00 2 Gloves $53.50 1 Whistle $5.00 S354 Socks $3.50 5 Mary Byrne Kildaman-fadar Rural R367 9/9/ Helmet $30.50 Anne Dunne N654 10/6/ Pants $13.75 Hat $11.00 Jim Feltz 20c Fake St D896 13/06/ $28.75 Boots $75.95

Summary of First Normal Form (1NF) A database is in the first normal form when Attributes store only atomic values Duplicate columns are removed

Moving to Second Normal Form First_ Name Last_ Address Zone Order _ID Date Product Cost Units John Murphy 123 Fake St Inner-city S345 31/12/ 2014 Football $20.00 2 Gloves $53.50 1 Whistle $5.00 S354 Socks $3.50 5 Mary Byrne Kildaman-fadar Rural R367 9/9/ Helmet $30.50 Anne Dunne N654 10/6/ Pants $13.75 Hat $11.00 Jim Feltz 20c Fake St D896 13/06/ $28.75 Boots $75.95

Second Normal Form Cust_ID Order _ID Date Product Cost Units Cust_ID 1 S345 31/12/ 2014 Football $20.00 2 Gloves $53.50 Whistle $5.00 S354 Socks $3.50 5 R367 9/9/ Helmet $30.50 3 N654 10/6/ Pants $13.75 Hat $11.00 4 D896 13/06/ $28.75 Boots $75.95 Cust_ID First_ Name Last_ Address Zone 1 John Murphy 123 Fake St Inner-city 2 Mary Byrne Kildaman-fadar Rural 3 Anne Dunne 4 Jim Feltz 20c Fake St

Second Normal Form (Continued) Cust_ ID Order _ID Date Product Units 1 S345 31/12/ 2014 2 3 S354 4 5 R367 9/9/ N654 10/6/ 6 7 D896 13/06/ 8 Cust_ ID First_ Name Last_ Address Zone 1 John Murphy 123 Fake St Inner-city 2 Mary Byrne Kildaman-fadar Rural 3 Anne Dunne 4 Jim Feltz 20c Fake St Product_ID Product_1 Cost_P1 1 Football $20.00 2 Gloves $53.50 3 Whistle $5.00 4 Socks $3.50 5 Helmet $30.50 6 Pants $13.75 7 Hat $11.00 8 Boots $75.95

Second Normal Form (Continued) Cust_ID Order _ID Product Units 1 S345 2 3 S354 4 5 R367 N654 6 7 D896 8 Cust_ ID First_ Name Last_ Address Zone 1 John Murphy 123 Fake St Inner-city 2 Mary Byrne Kildaman-fadar Rural 3 Anne Dunne 4 Jim Feltz 20c Fake St Order _ID Date S345 31/12/ 2014 S354 R367 09/09/ N654 10/6/ D896 13/06/ Product_ID Product_1 Cost_P1 1 Football $20.00 2 Gloves $53.50 3 Whistle $5.00 4 Socks $3.50 5 Helmet $30.50 6 Pants $13.75 7 Hat $11.00 8 Boots $75.95

Second Normal Form (Continued) Order _ID Product Units S345 1 2 3 S354 4 5 R367 N654 6 7 D896 8 Cust_ ID First_ Name Last_ Address Zone 1 John Murphy 123 Fake St Inner-city 2 Mary Byrne Kildaman-fadar Rural 3 Anne Dunne 4 Jim Feltz 20c Fake St Order _ID Date Cust_ ID S345 31/12/ 2014 1 S354 R367 09/09/ 2 N654 10/6/ 3 D896 13/06/ 4 Product_ID Product_1 Cost_P1 1 Football $20.00 2 Gloves $53.50 3 Whistle $5.00 4 Socks $3.50 5 Helmet $30.50 6 Pants $13.75 7 Hat $11.00 8 Boots $75.95

Summary of Second Normal Form (2NF) A database is in the second normal form when It satisfies the criteria for the first normal form Each non-candidate key is dependent on the whole candidate key (i.e. subsets of data across multiple rows are removed) Put differently, we have no partial dependencies via a concatenated key Takes advantage of reflexivity and augmentation

Moving to Third Normal Form Order _ID Product Units S345 1 2 3 S354 4 5 R367 N654 6 7 D896 8 Cust_ ID First_ Name Last_ Address Zone 1 John Murphy 123 Fake St Inner-city 2 Mary Byrne Kildaman-fadar Rural 3 Anne Dunne 4 Jim Feltz 20c Fake St Order _ID Date Cust_ ID S345 31/12/ 2014 1 S354 R367 09/09/ 2 N654 10/6/ 3 D896 13/06/ 4 Product_ID Product_1 Cost_P1 1 Football $20.00 2 Gloves $53.50 3 Whistle $5.00 4 Socks $3.50 5 Helmet $30.50 6 Pants $13.75 7 Hat $11.00 8 Boots $75.95

Moving to Third Normal Form Order _ID Product Units S345 1 2 3 S354 4 5 R367 N654 6 7 D896 8 Address Zone 123 Fake St Inner-city 20c Fake St Kildaman-fadar Rural Cust_ ID First_ Name Last_ Address 1 John Murphy 123 Fake St 2 Mary Byrne Kildaman-fadar 3 Anne Dunne 4 Jim Feltz 20c Fake St Order _ID Date Cust_ ID S345 31/12/ 2014 1 S354 R367 09/09/ 2 N654 10/6/ 3 D896 13/06/ 4 Product_ID Product_1 Cost_P1 1 Football $20.00 2 Gloves $53.50 3 Whistle $5.00 4 Socks $3.50 5 Helmet $30.50 6 Pants $13.75 7 Hat $11.00 8 Boots $75.95

Summary of Third Normal Form (3NF) A database is in the second normal form when It satisfies the criteria for the second normal form Each non-key attribute that depends on anything other than the entire primary key is removed (insertion anomalies are impossible) Put differently, we have no transitive dependencies via non-key attributes Takes advantage of transitivity

Readings Some more descriptions of normal forms http://databases.about.com/od/specificproducts/a/normalization.htm http://phlonx.com/resources/nf3/ http://www.bkent.net/Doc/simple5.htm