CCT395, Week 5 Translating ER into Relations; Normalization This presentation is licensed under Creative Commons Attribution License, v To view a.

Slides:



Advertisements
Similar presentations
ER Model For a college DB
Advertisements

FEN Introduction to the database field: Quality checking table design: Design Guidelines Normalisation Seminar: Introduction to relational.
Boyce-Codd NF Takahiko Saito Spring 2005 CS 157A.
Normalization What is it?
Normalization Dr. Mario Guimaraes. Data Normalization Primarily a tool to validate and improve a logical design so that it satisfies certain constraints.
1 Class Agenda (04/03 and 04/08)  Review and discuss HW #8 answers  Present normalization process Enhance conceptual knowledge of database design. Improve.
Modeling the Data: Conceptual and Logical Data Modeling
Jump to first page Normalization Jump to first page Topics n Why normalization is needed n What causes anomalies n What the 4 normal forms are n How.
Design Guidelines Normalisation Table Design. Informal Design Guidelines Table Semantics A table should hold information about one and only one entity/concept.
Normalization A technique for identifying table structures that have potential maintenance problems.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
Relational Data Analysis II. Plan Introduction Structured Methods –Data Flow Modelling –Data Modelling –Relational Data Analysis Feasibility Maintenance.
Project and Data Management Software
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.
Michael F. Price College of Business Chapter 6: Logical database design and the relational model.
COURSE REGISTRATION SYSTEM Case study IST2101. Case Study: Course Registration (1) IST2102 You are helping Penn State create a course registration system.
Normalization Rules for Database Tables Northern Arizona University College of Business Administration.
SQL Normalization Database Design Lecture 5. Copyright 2006Page 2 SQL Normalization Database Design 1 st Normal Form 1 st Normal Form 2 nd Normal Form.
1 Class Agenda (04/09 through 04/16)  Review HW #8  Present normalization process Enhance conceptual knowledge of database design. Improve practical.
1 Class Agenda (11/07 and 11/12)  Review HW #8 answers  Present normalization process Enhance conceptual knowledge of database design. Improve practical.
Functional Dependence An attribute A is functionally dependent on attribute(s) B if: given a value b for B there is one and only one corresponding value.
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.
Normalization Copyright © 1999 Patrick McDermott College of Alameda
Schema Refinement and Normal Forms 20131CS3754 Class Notes #7, John Shieh.
FEN Quality checking table design: Design Guidelines Normalisation Table Design Is this OK?
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.
IE 423 – Design of Decision Support Systems Data modeling and database development.
Database Design 3: Advanced Data Modeling Concepts CS 320.
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.
Functional dependencies and normalization 1 Normalization Functional dependencies NF + BCNF.
IE 423 – Design of Decision Support Systems Data modeling and database development.
McGraw-Hill/Irwin Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. Chapter 6 Modeling the Data: Conceptual and Logical Data Modeling.
Normalization ACSC 425 Database Management Systems.
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.
INF1343, Winter 2012 Data Modeling and Database Design Yuri Takhteyev Faculty of Information University of Toronto This presentation is licensed under.
CCT395, Week 4 Database Design and ER Modeling This presentation is licensed under Creative Commons Attribution License, v To view a copy of this.
INF1343, Winter 2011 Data Modeling and Database Design Yuri Takhteyev University of Toronto This presentation is licensed under Creative Commons Attribution.
INF1343, Week 6 Implementing a Database with SQL This presentation is licensed under Creative Commons Attribution License, v To view a copy of this.
CCT395, Week 11 Review, Permissions Physical Storage and Performance This presentation is licensed under Creative Commons Attribution License, v. 3.0.
CCT395, Week 6 Implementing a Database with SQL and a Case Study Exercise This presentation is licensed under Creative Commons Attribution License, v.
CCT396, Fall 2011 Database Design and Implementation Yuri Takhteyev University of Toronto This presentation is licensed under Creative Commons Attribution.
INF1343, Week 4 Database Design and ER Modeling This presentation is licensed under Creative Commons Attribution License, v To view a copy of this.
CCT396, Fall 2011 Database Design and Implementation Yuri Takhteyev University of Toronto This presentation is licensed under Creative Commons Attribution.
INF1343, Winter 2011 Data Modeling and Database Design Yuri Takhteyev University of Toronto This presentation is licensed under Creative Commons Attribution.
Database Design and Implementation
Translating ER into Relations; Normalization
Review Databases and Objects
University of Milano Bicocca Carlo Batini Course on Data Base Design
CS422 Principles of Database Systems Normalization
Special Topics in CCIT: Databases
SEEM3430: Information Systems Analysis and Design
University of Milano Bicocca, Italy Carlo Batini
CS422 Principles of Database Systems Normalization
Lecture 4 Database design IV Normal Forms: Summary.
Data Modeling and Database Design INF1343, Winter 2012 Yuri Takhteyev
Database Design and Implementation
Payroll Management System
Example Question–Is this relation Well Structured? Student
Data Modeling and Database Design INF1343, Winter 2012 Yuri Takhteyev
Entity relationship diagrams
Normalization Murali Mani.
Database solutions The process of normalization Marzena Nowakowska Faculty of Management and Computer Modelling Kielce University of Technology rooms:
Rob Gleasure IS6125 Database Analysis and Design Lecture 11: Normalization of Data Tables Rob Gleasure
Sampath Jayarathna Cal Poly Pomona
Sampath Jayarathna Cal Poly Pomona
Chapter 7: Entity-Relationship Model
Database Normalization.
Presentation transcript:

CCT395, Week 5 Translating ER into Relations; Normalization This presentation is licensed under Creative Commons Attribution License, v To view a copy of this license, visit This presentation incorporates images from the Crystal Clear icon collection by Everaldo Coelho, available under LGPL from Yuri Takhteyev University of Toronto October 6, 2010

course code title session code start date student last name first name room code capacity building code map url probably redundan t might be redundan t

course code title session code start date student last name first name room code capacity building code map url student enrolls in course course is offered in session course meets in room room is in building

course code title session code start date room code capacity building code map url student last name first name

course code title session code start date student last name first name room code capacity building code map url

course code title session code start date student last name first name room code capacity building code map url enrol lmen t

course code title session code start date student last name first name room code capacity building code map url enrol lmen t

course code title session code start date student last name first name room code capacity building code map url enrol lmen t cours e insta nce

course code title session code start date student last name first name room code capacity building code map url enrol lmen t cours e insta nce

course code title session code start date student last name first name room code capacity building code map url enrol lmen t cours e insta nce

course code title session code start date student last name first name room code capacity building code map url enrol lmen t cours e insta nce

course code title session code start date student last name first name room code capacity building code map url enrol lmen t cours e insta nce

course code title session code start date student last name first name room code capacity building code map url enrollment course instance final exam?

course code title session code start date student last name first name room code capacity building code map url enrollment course instance final exam?

Step 1 “Create one table for each entity” (after breaking up M:M)

student last name first name student

last name first name student

last name first name student

last name first name student

(do this for every entity)

Step 2 “For each entity that is only on the ‘one’ end of one or more relationships and not at the ‘many’ end of any relationship, create a single-column primary key... if no natural primary key is available.”

Step 2 “For each entity that is only on the ‘one’ end of one or more relationships and not at the ‘many’ end of any relationship, create a single-column primary key... if no natural primary key is available.”

course code title session code start date student last name first name room code capacity building code map url enrollment course instance final exam?

course code title session code start date student last name first name room code capacity building code map url enrollment course instance final exam?

course code title session code start date student last name first name room code capacity building code map url enrollment course instance final exam?

course code title session code start date student last name first name room code capacity building code map url enrollment course instance final exam?

course code title session code start date student last name first name room code capacity building code map url enrollment course instance final exam?

Step 2 “For each entity that is only on the ‘one’ end of one or more relationships and not at the ‘many’ end of any relationship, create a single-column primary key... if no natural primary key is available.”

Keys no key! student

Keys a candidate key student

Keys another candidate key student

Keys candidate #1 student candidate #2

Keys candidate #1 student candidate #2 candidate #1 primary key

Multi-Column Keys city a key!

Multi-Column Keys city a three column key

Multi-Column Keys city candidate #1 candidate #2

Step 2 “For each entity that is only on the ‘one’ end of one or more relationships and not at the ‘many’ end of any relationship, create a single-column primary key... if no natural primary key is available.”

student

let’s add it student

course code title session code start date student last name first name room code capacity building code map url enrollment course instance final exam?

course code* title session code* start date student last name first name student_id* room code capacity building code* map url enrollment course instance final exam?

course code title course_id* session code start date session_id* student last name first name student_id* room code capacity building code map url building_id* enrollment course instance final exam?

Step 3 “For each entity that is at the ‘many’ end of one or more relationships, include the primary key of each parent entity in the table as foreign keys.”

Step 3 “For each entity that is at the ‘many’ end of one or more relationships, include the primary key of each parent entity in the table as foreign keys.”

course code title course_id* session code start date session_id* student last name first name student_id* room code capacity building code map url building_id* enrollment course instance final exam?

course code title course_id* session code start date session_id student last name first name student_id* room code capacity building code map url building_id* enrollment course instance final exam?

Step 3 “For each entity that is at the ‘many’ end of one or more relationships, include the primary key of each parent entity in the table as foreign keys.”

course code title course_id* session code start date session_id* student last name first name student_id* room code capacity building code map url building_id* enrollment course instance final exam?

course code title course_id* session code start date session_id student last name first name student_id* room code capacity building code map url building_id* enrollment course instance final exam?

course code title course_id* session code start date session_id* student last name first name student_id* room code capacity building code map url building_id* enrollment course instance final exam?

course code title course_id* session code start date session_id* student last name first name student_id* room code capacity building_id building code map url building_id* enrollment student_id course instance final exam? course_id session_id

course code title course_id* session code start date session_id* student last name first name student_id* room code capacity building_id building code map url building_id* enrollment student_id course instance final exam? course_id session_id

Step 4a “If an entity at the ‘many’ end of one or more relationships, has a natural primary key, use that single key as a the primary key.”

course code title course_id* session code start date session_id* student last name first name student_id* room code capacity building_id building code map url building_id* enrollment student_id course instance final exam? course_id session_id

Step 4b “Otherwise, concatenate the primary key of its parent with any other column or columns needed for uniqueness to form the table’s primary key.”

course code title course_id* session code start date session_id* student last name first name student_id* room code capacity building_id building code map url building_id* enrollment student_id course instance final exam? course_id session_id

Step 4c If necessary, add a field!

course code title course_id* session code start date session_id* student last name first name student_id* room code capacity building_id room_id* building code map url building_id* enrollment student_id course instance final exam? course_id session_id

course code title course_id* session code start date session_id* student last name first name student_id* room code capacity building_id room_id* building code map url building_id* enrollment student_id course instance final exam? course_id session_id

Step 4d Go back to step 3!

course code title course_id* session code start date session_id* student last name first name student_id* room code capacity building_id room_id* building code map url building_id* enrollment student_id course instance final exam? course_id session_id room_id

course code title course_id* session code start date session_id* student last name first name student_id* room code capacity building_id room_id* building code map url building_id* enrollment student_id course instance final exam? course_id* session_id* room_id*

course code title course_id* session code start date session_id* student last name first name student_id* room code capacity building_id room_id* building code map url building_id* enrollment student_id course instance final exam? course_id* session_id* room_id*

course code title course_id* session code start date session_id* student last name first name student_id* room code capacity building_id room_id* building code map url building_id* enrollment student_id* instance_id * course instance final exam? course_id session_id room_id instance_id*

course code title course_id* session code start date session_id* student last name first name student_id* room code capacity building_id room_id* building code map url building_id* enrollment student_id* instance_id* course instance final exam? course_id session_id room_id instance_id*

course_instance

course code title course_id* session code start date session_id* student last name first name student_id* room code capacity building_id room_id* building code map url building_id* enrollment student_id* instance_id* course instance final exam? course_id session_id room_id instance_id*

course_instance

Step 5 Normalize!

Normalization Checking that the table does not have any well-known problems

What Problems?

Normal Forms 4 th Normal Form BC Normal Form 3 rd Normal Form 2 nd Normal Form 1 st Normal Form 5 th Normal Form trivial! you can do it! fixing weird issues

1NF No multi-valued attributes

The Wrong Solution

The Right Solution

2NF and 3NF Getting rid of “functional dependencies”

course title grade code student id course id student name “Each attribute must describe the key, grade points the whole key, and nothing but the key.” “So help me Codd!”

course title grade code student id course id student name “Each attribute must describe the key... grade points

course title grade code student id course id student name “Each attribute must describe the key, the whole key, and nothing but the key.” grade points partial dependency full dependency transitive dependency “So help me Codd!”

2NF: no partial dependencies (“the whole key”) 3NF: 2NF + no transitive dependencies (“nothing but the key”) 2NF and 3NF

Reaching 2NF and 3NF Decomposition (break up tables into several)

course title grade code student id course id student name grade points

course course title grade code student id course id student name course id student id grade points

course course title grade code student id course id student name grade points grade code course id student id

“all determinants must be candidate keys” BCNF

course time slot instructor id room id course code overlapping candidate keys

course time slot instructor id room id dependencies between keys

course time slot instructor id room id dependencies between keys

course time slot instructor id instructor utorid this is 3NF, but not BCNF (“so help me Codd”)

course time slot instructor id instructor utorid decompose it instructor id

course course id project id student id some relations cannot be decomposed into BCNF (“so help me Codd”) student, course → project project → course

Mistaking binary relationships for ternary 4NF

course code title session code start date room code capacity

course code title session code start date room code capacity cours e insta nce

student job course

5NF “We could break it up yet more”

Questions?