Classroom Exercise: Normalization

Slides:



Advertisements
Similar presentations
Schema Refinement: Normal Forms
Advertisements

Schema Refinement: Canonical/minimal Covers
Non Trivial FD. Candidate Key FD’s that Hold on S.
Normalization Decomposition techniques for ensuring: Lossless joins Dependency preservation Redundancy avoidance We will look at some normal forms: Boyce-Codd.
Logical Database Design (3 of 3) John Ortiz. Lecture 7Logical Database Design (2)2 Normalization  If a relation is not in BCNF or 3NF, we refine it by.
CS 440 Database Management Systems Practice problems for normalization.
Review for Final Exam Lecture Week 14. Problems on Functional Dependencies and Normal Forms.
Normalization theory exercises Dr. Shiyong Lu Department of Computer Science Wayne State University ©copyright 2007, all rights reserved.
1 Design Theory. 2 Minimal Sets of Dependancies A set of dependencies is minimal if: 1.Every right side is a single attribute 2.For no X  A in F and.
1 Normalization. 2 Normal Forms v If a relation is in a certain normal form (BCNF, 3NF etc.), it is known that certain kinds of redundancies are avoided/minimized.
CS Algorithm : Decomposition into 3NF  Obviously, the algorithm for lossless join decomp into BCNF can be used to obtain a lossless join decomp.
Decomposition By Timothy Chen CS157A. Goal to Decomposition Eliminate redundancy by decomposing a relation into several relations in a higher normal form.
Normalization DB Tuning CS186 Final Review Session.
Relational Design. DatabaseDesign Process Conceptual Modeling -- ER diagrams ER schema transformed to relational schema Designer may add additional integrity.
Normalization DB Tuning CS186 Final Review Session.
1 Classroom Exercise: Normalization u Consider the relation R(A,B,C,D) with these given FDs: w AB -> C w C -> D w D -> A u Compute all nontrivial FDs that.
Closure The closure of {B 1 …B k } under the set of FDs S, denoted by {B 1 …B k } +, is defined as follows: {B 1 …B k } + = {B | any relation satisfies.
1 Functional Dependencies Meaning of FD’s Keys and Superkeys Inferring FD’s.
1 Introduction to Database Systems CSE 444 Lectures 8 & 9 Database Design April 16 & 18, 2008.
Normal Form Design addendum by C. Zaniolo. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Normal Form Design Compute the canonical cover.
Design Theory.
The principal problem that we encounter is redundancy, where a fact is repeated in more than one tuple. Most common cause: attempts to group into one relation.
Lossless Decomposition Prof. Sin-Min Lee Department of Computer Science San Jose State University.
Decomposition By Yuhung Chen CS157A Section 2 October
M.P. Johnson, DBMS, Stern/NYU, Spring C : Database Management Systems Lecture #7 Matthew P. Johnson Stern School of Business, NYU Spring,
Normalization. FarkasCSCE 5202 Reading Assignments  Database Systems The Complete Book: Chapters 3.6, 3.7, 3.8  Following lecture slides are modified.
Cs3431 Normalization Part II. cs3431 Attribute Closure : Example Consider R (A, B, C, D, E) with FDs A  B, B  C, CD  E Does A  E hold ? (Is A  E.
Boyce-Codd NF & Lossless Decomposition Professor Sin-Min Lee.
MVDs: 1 Join Dependencies—Example Let r = A B C = A B |  | A C 1 a x 1 a 1 x 1 a y 1 b 1 y 1 b x 2 a 2 y 1 b y 2 b 2 a y 2 b y Observe: r =  AB r | 
Fall 2001Arthur Keller – CS 1804–1 Schedule Today Oct. 4 (TH) Functional Dependencies and Normalization. u Read Sections Project Part 1 due. Oct.
1 Triggers: Correction. 2 Mutating Tables (Explanation) The problems with mutating tables are mainly with FOR EACH ROW triggers STATEMENT triggers can.
1 Normalization Anomalies Boyce-Codd Normal Form 3 rd Normal Form.
Multi-valued Dependencies and Fourth Normal Form
Decompositions uDo we need to decompose a relation? wSeveral normal forms for relations. If schema in these normal forms certain problems don’t.
Normal Forms1. 2 The Problems of Redundancy Redundancy is at the root of several problems associated with relational schemas: Wastes storage Causes problems.
Chapter 8: Relational Database Design First Normal Form First Normal Form Functional Dependencies Functional Dependencies Decomposition Decomposition Boyce-Codd.
DAVID DENG CS157B MARCH 23, 2010 Dependency Preserving Decomposition.
CS143 Review: Normalization Theory Q: Is it a good table design? We can start with an ER diagram or with a large relation that contain a sample of the.
CSCI 4333 Database Design and Implementation – Exercise (3) Xiang Lian The University of Texas – Pan American Edinburg, TX
SCUJ. Holliday - coen 1784–1 Schedule Today: u Normal Forms. u Section 3.6. Next u Relational Algebra. Read chapter 5 to page 199 After that u SQL Queries.
THIRD NORMAL FORM (3NF) A relation R is in BCNF if whenever a FD XA holds in R, one of the following statements is true: XA is a trivial FD, or X is.
Functional Dependencies and Normalization 1 Instructor: Mohamed Eltabakh
CS 564 Database Management Systems: Design and Implementation Discussion Session Friday, Sept 18, Apul Jain.
Functional Dependencies. FarkasCSCE 5202 Reading and Exercises Database Systems- The Complete Book: Chapter 3.1, 3.2, 3.3., 3.4 Following lecture slides.
Third Normal Form (3NF) Zaki Malik October 23, 2008.
Section 3 CSE 444 Introduction to Databases. Announcements Project 1 was due yesterday (10/14/2009) Homework 1 was released, due 10/28/2009.
1 Lecture 10: Database Design Wednesday, January 26, 2005.
CONSENSUS THEOREM Choopan Rattanapoka.
Design Theory for RDB Normal Forms. Lu Chaojun, SJTU 2 Redundant because these info may be figured out by using FD s1  … What’s Bad Design? Redundancy.
Multivalued Dependencies Fourth Normal Form Tony Palladino 157B.
Functional Dependencies CIS 4301 Lecture Notes Lecture 8 - 2/7/2006.
Multivalued Dependencies and 4th NF CIS 4301 Lecture Notes Lecture /21/2006.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
© D. Wong Functional Dependencies (FD)  Given: relation schema R(A1, …, An), and X and Y be subsets of (A1, … An). FD : X  Y means X functionally.
1 Lecture 9: Database Design Wednesday, January 25, 2006.
Normalization and FUNctional Dependencies. Redundancy: root of several problems with relational schemas: –redundant storage, insert/delete/update anomalies.
Design Theory for Relational Databases Functional Dependencies Decompositions Normal Forms: BCNF, Third Normal Form Introduction to Multivalued Dependencies.
4NF & MULTIVALUED DEPENDENCY By Kristina Miguel. Review  Superkey – a set of attributes which will uniquely identify each tuple in a relation  Candidate.
Lecture 34 Section 6.7 Wed, Mar 28, 2007
Relational Database Design (Discussion Session)
Normalization First Normal Form (1NF) Boyce-Codd Normal Form (BCNF)
Problems in Designing Schema
How to test Whether Subschemes in BCNF??
Exercise R(A,B,C,D) with FD’s ABC, CD, and DA
Fractional Factorial Design
Some slides are from Dr. Sara Cohen
Instructor: Mohamed Eltabakh
Design matrix Run A B C D E
Quiz 2 Let R(A,B,C,D) be a relation schema with
CS4222 Principles of Database System
Presentation transcript:

Classroom Exercise: Normalization Consider the relation R(A,B,C,D) with these given FDs: AB -> C C -> D D -> A Compute all nontrivial FDs that follow from these. Compute the key(s) for R. What are all the superkeys? What are all the BCNF violations? Decompose R into BCNF. What are all the 3NF violations (before decomposing into BCNF)? Decompose R into 3NF.

Consider the relation R(A,B,C,D) with these given FDs: AB -> C C -> D D -> A Compute all nontrivial FDs that follow from these. 1. For each set of attributes X, compute X+: A+ = A; B+ = B; C+ = CDA; D+ = DA; AB+ = ABCD; AC+ = ACD; AD+ = AD; BC+ = BCDA; BD+ = BDAC; CD+ = CDA; ABC+ = ABCD; ABD+ = ABCD; ACD+ = ACD; BCD+ = BCDA 2. New FDs are of form X -> A for all A in X+; drop trivial ones A -> A; B -> B; C -> CDA; D -> DA; AB -> ABCD; AC -> ACD; AD -> AD; BC -> BCDA; BD -> BDA; CD -> CDA; ABC -> ABCD; ABD -> ABCD; ACD -> ACD; BCD -> BCDA 3. Drop redundant ones (if we have X -> A, don't need XY -> A): C -> D; C -> A; D -> A, AB -> C; AB -> D; AC -> D; BC -> D; BC -> A; BD -> A; CD -> A; ABC -> D; ABD -> C; BCD -> A

So the relation R(A,B,C,D) has these FDs: C -> D (given originally) C -> A D -> A (given originally) AB -> C (given originally) AB -> D Compute the key(s) for R. three keys: AB, BC, and BD What are all the superkeys? every superset of a key: ABC, ABD, BCD, ABCD What are all the BCNF violations? any FD whose LHS does not contain a key: C -> D; C -> A; D -> A

Let's start with C -> D. Decompose R into BCNF. Start with violating FD X -> A. Compute X+. New relations are R1 with attributes X+ and R2 with attributes R - X+ U X. Project R's FD's onto R1 and R2. Check if need to decompose some more. Let's start with C -> D. Compute C+ = CDA. New relation R1(C,D,A): FD's for R1: C -> D, C -> A, D -> A key for R1: C D -> A violates BCNF, need to decompose New relation R2(B,C): FD's for R2: none key for R2: BC in BCNF

Decompose R1(C,D,A) with FD's C -> D; C -> A; D -> A and key C Start with D -> A: Compute D+ = DA new relation R3(D,A) with FD D -> A and key D. Is in BCNF. new relation R4(C,D) with FD C -> D and key C. Is in BCNF. Final set of BCNF relation schemas: R2(B,C), R3(D,A), and R4(C,D)

What about decomposing into 3NF? Original relation is R(A,B,C,D) We already discovered the FD's: C -> D (given originally) C -> A D -> A (given originally) AB -> C (given originally) AB -> D We already discovered the keys: AB, BC, BD What are the 3NF violations (LHS does not contain a key AND RHS is not part of a key)? None! Every attribute is part of a key, so no FD violates FD. Thus no decomposition is necessary.