Advanced Normalization

Slides:



Advertisements
Similar presentations
B. Information Technology CMPB245: Database Design Normalization Pt. 2.
Advertisements

The Relational Model System Development Life Cycle Normalisation
1 Database Systems: A Practical Approach to Design, Implementation and Management International Computer Science S. Carolyn Begg, Thomas Connolly Lecture.
Database Design Conceptual –identify important entities and relationships –determine attribute domains and candidate keys –draw the E-R diagram Logical.
CS 3630 Database Design and Implementation. First Normal Form (1NF) No multi-value attributes Done when mapping E-R model to relational schema DBDL 2.
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.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
Lecture 12 Inst: Haya Sammaneh
Chapter 6 Normalization 正規化. 6-2 In This Chapter You Will Learn:  更動異常  How tables that contain redundant data can suffer from update anomalies ( 更動異常.
Normalization. 2 Objectives u Purpose of normalization. u Problems associated with redundant data. u Identification of various types of update anomalies.
RDBMS Concepts/ Session 3 / 1 of 22 Objectives  In this lesson, you will learn to:  Describe data redundancy  Describe the first, second, and third.
Database Management COP4540, SCS, FIU Relation Normalization (Chapter 14)
Normalization. Learners Support Publications 2 Objectives u The purpose of normalization. u The problems associated with redundant data.
Lecture 6 Normalization: Advanced forms. Objectives How inference rules can identify a set of all functional dependencies for a relation. How Inference.
Lecture9:Functional Dependencies and Normalization for Relational Databases Prepared by L. Nouf Almujally Ref. Chapter Lecture9 1.
CSC271 Database Systems Lecture # 28.
CSC271 Database Systems Lecture # 29. Summary: Previous Lecture  The normalization process  1NF, 2NF, 3NF  Inference rules for FDs  BCNF.
Normalization Fundamentals of Database Systems. Lilac Safadi Normalization 2 Database Design Steps in building a database for an application: Real-world.
Chapter 10 Functional Dependencies and Normalization for Relational Databases Copyright © 2004 Pearson Education, Inc.
Chapter 13 Normalization. 2 Chapter 13 - Objectives u Purpose of normalization. u Problems associated with redundant data. u Identification of various.
Chapter 13 Normalization Transparencies Last Updated: 08 th May 2011 By M. Arief
Chapter 10 Normalization Pearson Education © 2009.
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.
Lecture9:Functional Dependencies and Normalization for Relational Databases Ref. Chapter Lecture9 1.
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
Dr. Mohamed Osman Hegaz1 Logical data base design (2) Normalization.
9/23/2012ISC329 Isabelle Bichindaritz1 Normalization.
Normalization. 2 u Main objective in developing a logical data model for relational database systems is to create an accurate representation of the data,
Second Normal Form (2NF) A relation R is in 1NF, and every non-primary-key attribute is fully functionally dependent on the primary key Then R is in 2NF.
11/10/2009GAK1 Normalization. 11/10/2009GAK2 Learning Objectives Definition of normalization and its purpose in database design Types of normal forms.
ITD1312 Database Principles Chapter 4C: Normalization.
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
1 CS490 Database Management Systems. 2 CS490 Database Normalization.
Chapter 9 Normalization Chapter 14 & 15 in Textbook.
Functional Dependencies and Normalization for Relational Databases تنبيه : شرائح العرض (Slides) هي وسيلة لتوضيح الدرس واداة من الادوات في ذلك. حيث المرجع.
Chapter 8 Relational Database Design Topic 1: Normalization Chuan Li 1 © Pearson Education Limited 1995, 2005.
Normalization.
Normalization Normalization is a formal method involved with a series of test to help database designer to be able to identify the optimal grouping.
Advanced Normalization
Normalization Karolina muszyńska
CS 3630 Database Design and Implementation
Normalization DBMS.
Normalization Dongsheng Lu Feb 21, 2003.
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
Relational Database Design by Dr. S. Sridhar, Ph. D
Advanced Normalization
Normalization Lecture 7 May Aldoayan.
Chapter 14 Normalization
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
Normalization.
Database Normalization
Relational Design Theory
Normalization Murali Mani.
CS 3630 Database Design and Implementation
Chapter 14 & Chapter 15 Normalization Pearson Education © 2009.
Normalization.
Normalization Dongsheng Lu Feb 21, 2003.
Chapter 7 Normalization Chapter 13 in Textbook.
Chapter 14 Normalization – Part I Pearson Education © 2009.
Database solutions The process of normalization Marzena Nowakowska Faculty of Management and Computer Modelling Kielce University of Technology rooms:
Normalization Dale-Marie Wilson, Ph.D..
Normalization.
Chapter 14 Normalization.
Normalization February 28, 2019 DB:Normalization.
國立臺北科技大學 課程:資料庫系統 2015 fall Chapter 14 Normalization.
Chapter 7 Normalization Chapter 14 & 15 in Textbook.
Database Design Normalisation (2)
Presentation transcript:

Advanced Normalization Chapter 15 Advanced Normalization

Chapter 15 - Objectives Normal forms that go beyond Third Normal Form (3NF), which includes Boyce-Codd Normal Form (BCNF), Fourth Normal Form (4NF), and Fifth Normal Form (5NF). How to identify Boyce–Codd Normal Form (BCNF). How to represent attributes shown on a report as BCNF relations using normalization.

Chapter 15 - Objectives Concept of multi-valued dependencies and Fourth Normal Form (4NF). The problems associated with relations that break the rules of 4NF. How to create 4NF relations from a relation, which breaks the rules of to 4NF.

Boyce–Codd Normal Form (BCNF) Based on functional dependencies that take into account all candidate keys in a relation, however BCNF also has additional constraints compared with the general definition of 3NF. Boyce–Codd normal form (BCNF) A relation is in BCNF if and only if every determinant is a candidate key.

Boyce–Codd Normal Form (BCNF) Difference between 3NF and BCNF is that for a functional dependency A  B, 3NF allows this dependency in a relation if B is a primary-key attribute and A is not a candidate key. Whereas, BCNF insists that for this dependency to remain in a relation, A must be a candidate key. Every relation in BCNF is also in 3NF. However, a relation in 3NF is not necessarily in BCNF.

Boyce–Codd Normal Form (BCNF) Violation of BCNF is quite rare. The potential to violate BCNF may occur in a relation that: contains two (or more) composite candidate keys; the candidate keys overlap, that is have at least one attribute in common.

Review of Normalization (UNF to BCNF)

Review of Normalization (UNF to BCNF) StaffProperyInspection in UNF Must handle multi-valued attribute to get to 1NF

Review of Normalization (UNF to BCNF) StaffPropertyInspection in 1NF 2 tuples -> 5 tuples

Identify all Functional Dependencies in 1NF version

1NF -> 2NF 1NF 1NF -> 2NF StaffPropertyInspection (propertyNo, iDate, iTime, pAddress, comments, staffNo, sName, carReg) Primary key: propertyNo, iDate Functional dependencies fd1 to fd6 (see previous slide) 1NF -> 2NF Remove partial fd (fd2): propertyNo -> pAddress Create 2 tables from StaffPropertyInspection PropertyInspection & Property

2NF -> 3NF 2NF 2NF -> 3NF PropertyInspection (propertyNo, iDate, iTime, comments, staffNo, sName, carReg) Property (propertyNo, pAddress) 2NF -> 3NF Remove transitive fd (fd3) from PropertyInspection fd1 propertyNo, iDate -> … staffNo.. fd3 staffNo-> sName Create 2 tables from PropertyInspection PropertyInspect & Staff

3NF Schema PropertyInspect (propertyNo, iDate, iTime, comments, staffNo, carReg) fd1’ propertyNo, iDate -> iTime, comments, staffNo, sName, carReg fd4 staffNo, iDate -> carReg fd5’ carReg, iDate, iTime -> propertyNo, commends, staffNo fd6’ staffNo, iDate, iTime -> propertyNo, comments Property (propertyNo, pAddress) fd2 propertyNo -> pAddress Staff (staffNo, sName) fd3 staffNo -> sName

3NF -> BCNF All determinants (lhs) must be candidate keys Staff and Property in BCNF PropertyInspect: not in BCNF fd4 staffNo, iDate -> carReg Staff assigned same car for the whole day staffNo, iDate is not a candidate key for PropertyInspect Staff could inspect >1 properties on the same day (domain knowledge) Create two new relations from PropertyInspect Inspection (propertyNo, iDate, iTime, comments, staffNo) StaffCar (staffNo iDate, carReg)

BCNF Schema Inspection (propertyNo, iDate, iTime, comments, staffNo) fd1’’ propertyNo, iDate -> iTime, comments, staffNo, sName fd5’’ iDate, iTime -> propertyNo, comments, staffNo fd6’ staffNo, iDate, iTime -> propertyNo, comments Property (propertyNo, pAddress) fd2 propertyNo -> pAddress Staff (staffNo, sName) fd3 staffNo -> sName StaffCarReg (staffNo, iDate, carReg) fd4 staffNo, iDate -> carReg

Review of Normalization (1NF to BCNF)

Fourth Normal Form (4NF) Multi-valued Dependency (MVD) Dependency between attributes (for example, A, B, and C) in a relation, such that for each value of A there is a set of values for B and a set of values for C. However, the set of values for B and C are independent of each other. Defined as a relation that is in Boyce-Codd Normal Form and contains no nontrivial multi-valued dependencies.

Fourth Normal Form (4NF) MVD between attributes A, B, and C in a relation using the following notation: A −>> B A −>> C

Example BranchStaffOwner Has two independent, mulivalued dependencies in same table: branchNo ->> sName (branches have multiple staff) branchNo ->> oName (branches have multiple properties which may have different owners) End up having to duplicate tuples to show each staff member with each owner E.g., add a new staff member, have to add 2 new tuples, one for each oName Solution: make a separate relation for each dependency

4NF - Example

Fifth Normal Form (5NF) Only rarely does a 4NF not conform to 5NF In 5NF if cannot be decomposed into further relations with a lossless join i.e., if you decompose a table into multiple tables If you rejoin it with a natural join You get original table back, with no errors

Fifth Normal Form (5NF) In other words, in 5NF, all relations are decomposed into as many relations as possible without introducing errors All tables are key, and attributes that depend on key; no other fd

5NF Do NOT decompose tables if all attributes depend on same key E.g., <SSN, Name, Birthdate, Zip> stays in one table Do not decompose into <SSN, Name> <SSN, Birthdate> <SSN, Zip>

5NF – Example (table is in 4NF) Traveling Salesman Brand Product Type Jack Schneider Acme Vacuum Cleaner Breadbox Mary Jones Robusto Pruning Shears Umbrella Stand Louis Ferguson Telescope Lava Lamp Nimbus Tie Rack

5NF - Example Primary Key: Composite of all three attributes (Traveling Salesman, Brand, Product Type) In 4NF Suppose there is a rule that, if a salesman offers the same product from TWO different Brands Then he must offer all other products from those brands IF he sells those products at all

5NF - Example So, If Jack Schneider starts to sell Robusto’s Vacuum Cleaners He must also now sell Robusto’s Breadboxes, too, because he sells Breadboxes But, he doesn’t sell Pruning Shears or Umbrella Stands (from Robusto) or Lava Lamps (from Acme) That’s okay If not in 5NF, Need logic in the insert function to enforce rules Add 2 tuples <Jack Schneider, Robusto, Vacuum Cleaner> <Jack Schneider, Robusto, Breadbox> Possibility of update/insert/deletion errors

5NF - Example Instead, decompose into 3 relations: Traveling Salesman -> Product Type Traveling Salesman -> Brand Brand -> Product Type Now, table design excludes possibility of inconsistencies He starts selling Robusto Vaccuum cleaners Add <Jack Schneider, Robusto> to TravellingSalesman+Brand table Captures that he sells Breadboxes and Vacuum Cleaners from Robusto and Acme

5NF - Example Traveling Salesman Brand Jack Schneider Acme Mary Jones Robusto Louis Ferguson Nimbus Traveling Salesman Product Type Jack Schneider Vacuum Cleaner Breadbox Mary Jones Pruning Shears Umbrella Stand Louis Ferguson Telescope Lava Lamp Tie Rack Brand Product Type Acme Vacuum Cleaner Breadbox Lava Lamp Robusto Pruning Shears Umbrella Stand Telescope Nimbus Tie Rack

5NF - Example Need to join all 3 relations to get original relation Can get spurious tuples by just joining two relations E.g., join <Jack Schneider, Acme> with <Acme, Lava Lamp> Conclude that Jack sells Acme Lava Lamps and he doesn’t Must join with all 3 relations <Jack Schneider, Acme> with <Jack Schneider, Vacuum Cleaner> AND <Jack Schneider, Breadbox> with <Acme, Vacuum Cleaner> <Acme, Breadbox> <Acme, Lava Lamp>

Normalization Summary As we normalize, we change schema to contain more and more tables with fewer and fewer attributes in each table Reduces redundancy BUT need to do joins to answer queries E.g., can get sName for a given date, time an property from StaffPropertyInspection (2NF) Need to join PropertyInspect and Staff on staffNo to get the name in 3NF Classic time/space trade-off in CS

Normalization Summary If you do an object-oriented design of your database, you will be generally be in 4NF E.g., classes (relations) for: property, staff, owners, cars, etc… Attributes for each class in the relation for that class