Normalization continued CMSC 461 Michael Wilson. Normalization clarification  Normalization is simply a way of reducing anomalous database behavior 

Slides:



Advertisements
Similar presentations
Chapter 5 Normalization of Database Tables
Advertisements

FEN Introduction to the database field: Quality checking table design: Design Guidelines Normalisation Seminar: Introduction to relational.
Schema Refinement: Normal Forms
Shantanu Narang.  Background  Why and What of Normalization  Quick Overview of Lower Normal Forms  Higher Order Normal Forms.
Boyce-Codd normal form (BCNF) Kai Zhu CS157B Professor: Dr. Lee.
INLS 623 – D ATABASE N ORMALIZATION Instructor: Jason Carter.
Normal Forms By Christopher Archibald October 16 th 2007.
September 24, R McFadyen1 The objective of normalization is sometimes stated “to create relations where every dependency is on the primary.
Functional Dependency CS157a Sec. 2 Koichiro Hongo.
Normalization of Database Tables
Design Guidelines Normalisation Table Design. Informal Design Guidelines Table Semantics A table should hold information about one and only one entity/concept.
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.
Some Simple Normalization Steps CIT 381. What Normalization Is For Avoid redundancy “One fact in one place” Analyze dependencies among attributes May.
Normalization of Database Tables
Normalization of Database Tables
Chapter 5 Normalization of Database Tables
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 5 Normalization of Database Tables.
Why Normalization? To Reduce Redundancy to 1.avoid modification, insertion, deletion anomolies 2.save space Goal: One Fact in One Place.
1 Triggers: Correction. 2 Mutating Tables (Explanation) The problems with mutating tables are mainly with FOR EACH ROW triggers STATEMENT triggers can.
1 Lecture 7: Schema refinement: Normalisation
Normalization II. Boyce–Codd Normal Form (BCNF) Based on functional dependencies that take into account all candidate keys in a relation, however BCNF.
Chapter 14 Advanced Normalization Transparencies © Pearson Education Limited 1995, 2005.
Chapter 8 Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Introduction to Schema Refinement
Chapter 10 Functional Dependencies and Normalization for Relational Databases.
Database Systems Normal Forms. Decomposition Suppose we have a relation R[U] with a schema U={A 1,…,A n } – A decomposition of U is a set of schemas.
Relational databases and third normal form As always click on speaker notes under view when executing to get more information!
NormalizationNormalization Chapter 4. Purpose of Normalization Normalization  A technique for producing a set of relations with desirable properties,
Database Systems: Design, Implementation, and Management Tenth Edition
RDBMS Concepts/ Session 3 / 1 of 22 Objectives  In this lesson, you will learn to:  Describe data redundancy  Describe the first, second, and third.
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Database Systems: Design, Implementation, and Management Ninth Edition Chapter 6 Normalization of Database Tables.
1 DATABASE SYSTEMS DESIGN IMPLEMENTATION AND MANAGEMENT INTERNATIONAL EDITION ROB CORONEL CROCKETT Chapter 7 Normalisation.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Normalization for Relational Databases.
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
BIS Database Systems School of Management, Business Information Systems, Assumption University A.Thanop Somprasong Chapter # 5 Normalization of Database.
Design Theory for Relational Databases 2015, Fall Pusan National University Ki-Joune Li.
FEN Quality checking table design: Design Guidelines Normalisation Table Design Is this OK?
Normal Forms through BCNF CPSC 356 Database Ellen Walker Hiram College (Includes figures from Database Systems by Connolly & Begg, © Addison Wesley 2002)
Functional Dependencies and Normalization for Relational Databases.
By Abdul Rashid Ahmad. E.F. Codd proposed three normal forms: The first, second, and third normal forms 1NF, 2NF and 3NF are based on the functional dependencies.
M1G Introduction to Database Development 4. Improving the database design.
1 Functional Dependencies and Normalization Chapter 15.
Normalization of Database Tables
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.
1 CSE 480: Database Systems Lecture 18: Normal Forms and Normalization.
Dr. Mohamed Osman Hegaz1 Logical data base design (2) Normalization.
9/23/2012ISC329 Isabelle Bichindaritz1 Normalization.
Normalization MIS335 Database Systems. Why Normalization? Optimizing database structure Removing duplications Accelerating the instructions Data integrity!
Normalization.
Chapter 5.1 and 5.2 Brian Cobarrubia Database Management Systems II January 31, 2008.
Functional dependencies and normalization 1 Normalization Functional dependencies NF + BCNF.
Database Systems, 8 th Edition Improving the Design Table structures cleaned up to eliminate initial partial and transitive dependencies Normalization.
Brian Thoms.  Databases normalization The systematic way of ensuring that a database structure is suitable for general-purpose querying and free of certain.
11/10/2009GAK1 Normalization. 11/10/2009GAK2 Learning Objectives Definition of normalization and its purpose in database design Types of normal forms.
11/06/97J-1 Principles of Relational Design Chapter 12.
1 CS 430 Database Theory Winter 2005 Lecture 8: Functional Dependencies Second, Third, and Boyce-Codd Normal Forms.
Copyright © Curt Hill Schema Refinement II 2 nd NF to 3 rd NF to BCNF.
Normal Forms (Part 1) Steven Le ~ CS157B. Normalization is a systematic way of ensuring that a database structure is suitable for general-purpose querying.
5 1 Chapter 5 Normalization of Database Tables Database Systems: Design, Implementation, and Management, Sixth Edition, Rob and Coronel.
Databases : Design of Relational Database Schemas 2007, Fall Pusan National University Ki-Joune Li.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
Database, tables and normal forms
Advanced Normalization
Advanced Normalization
Design Theory for Relational Databases
Chapter 14 & Chapter 15 Normalization Pearson Education © 2009.
Design Theory for Relational Databases
Presentation transcript:

Normalization continued CMSC 461 Michael Wilson

Normalization clarification  Normalization is simply a way of reducing anomalous database behavior  It’s not a required or programmatically necessary concept  A database will function perfectly fine without normalized tables  The table design will just suck

First normal form (1NF)  Each attribute only has atomic values  None of the elements on a relation in 1NF have elements which are sets  The elements cannot be further broken down  A bad 1NF attribute and example value:  phoneNumberAndFirstName: ,Jason

First normal form (1NF)  Furthermore  There are no duplicate rows  This means that there must be a key  This is important for higher normalization forms

Second normal form (2NF)  Must be in 1NF  Non-prime attributes are dependent on the whole of a candidate key  Not a partial candidate key – not 2NF  Non-prime = attributes not part of a candidate key  One thing to keep in mind  Multiple candidate keys may occur within one table  As long as the non-prime attributes depend on a candidate key, it is sufficiently 2NF

Reminder  Candidate key = minimal uniquely identifying set of attributes

2NF example EmployeeSkillWork Location BrownLight Cleaning73 Industrial Way BrownTyping73 Industrial Way HarrisonLight Cleaning73 Industrial Way JonesShorthand114 Main Street JonesTyping114 Main Street JonesWhittling114 Main Street

2NF example  Jacked shamelessly from wikipedia  Good example, though  Neither Employee or Skill can be a key here  Key must be {Employee, Skill}  Here, the work location depends on the employee alone  How to solve this?

Third normal form (3NF)  Must be in 2NF  Every non-prime attribute must be directly dependent on every superkey in a relation  X→A where X is a superkey and A is a non- prime attribute  Must hold for every superkey and every non- prime attribute

Reminder  Superkey – uniquely identifying set of attributes

Third normal form (3NF)  Another definition:  For every functional dependency X→A, one of the following must hold:  X→A is trivial  X is a superkey  Every element of the set difference between A and X is a prime attribute – part of a candidate key

3NF example TournamentYearWinnerWinner DOB Indiana Invitational 1998Al Frederickson 21 July 1975 Cleveland Open 1999Bob Albertson 28 September 1968 Des Moines Masters 1999Al Frederickson 21 July 1975 Indiana Invitational 1999Chip Masterson 14 March 1977

3NF example  Also jacked from wikipedia  This table is in 2NF  What are the candidate keys?  What are the superkeys?

3NF example  The winner functionally determines the winner date of birth  Transitive dependency of a non-prime attribute  Therefore, 3NF violation  How do we fix this?

Boyce-Codd Normal Form  Often called 3.5NF  Only states two things  For every functional dependency of the form X→A, one of the following must hold:  X→A is trivial  X is a superkey for the relation

Difference between 3NF and BCNF?  It’s actually pretty straightforward  3NF says that non-prime attributes must be dependent on a key  However, it does not say anything about prime attributes  Parts of the key can be dependent on candidate keys  BCNF tables satisfy 3NF, but not necessarily the reverse

3NF and BCNF  BCNF is only slightly more strict than 3NF  Only time you run into issues is when candidate keys overlap in 3NF  Possible to have a 3NF relation that is not BNF when candidate keys overlap

What to use?  3NF is very popular, most common  BCNF is also very popular  Recommendation  Shoot for 3NF to begin with  Very sensible way of organizing your data  Tables only have information that describes the key

Denormalization  Though normalization helps us rely on our data, denormalization is sometimes required for performance reasons  Often, one will need to re-add redundant data  Minimizes joins, selects, views, etc.  In high performance applications, one extra select could cause crippling response issues

When to denormalize?  Not at first!  If you don’t know that you’re going to run into performance issues, then don’t denormalize  Always try to keep things in a normalized form if possible  Later  Once you’ve identified issues through testing and statistics, denormalize if necessary