CS 440 Database Management Systems Practice problems for normalization.

Slides:



Advertisements
Similar presentations
Schema Refinement: Normal Forms
Advertisements

Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 16 Relational Database Design Algorithms and Further Dependencies.
Normalization 1 Instructor: Mohamed Eltabakh Part II.
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.
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.
CS 440 Database Management Systems Lecture 4: Constraints, Schema Design.
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.
Database Management COP4540, SCS, FIU Functional Dependencies (Chapter 14)
Properties of Armstrong’s Axioms Soundness All dependencies generated by the Axioms are correct Completeness Repeatedly applying these rules can generate.
CMPT 354, Simon Fraser University, Fall 2008, Martin Ester 227 Database Systems I Design Theory for Relational Databases.
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.
Classroom Exercise: Normalization
Normalization DB Tuning CS186 Final Review Session.
Normalization DB Tuning CS186 Final Review Session.
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.
CMSC424: Database Design Instructor: Amol Deshpande
Normal Form Design addendum by C. Zaniolo. ©Silberschatz, Korth and Sudarshan7.2Database System Concepts Normal Form Design Compute the canonical cover.
1 Normalization Chapter What it’s all about Given a relation, R, and a set of functional dependencies, F, on R. Assume that R is not in a desirable.
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.
1 CMSC424, Spring 2005 CMSC424: Database Design Lecture 9.
Decomposition By Yuhung Chen CS157A Section 2 October
Schema Refinement and Normalization Nobody realizes that some people expend tremendous energy merely to be normal. Albert Camus.
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.
Fall 2001Arthur Keller – CS 1804–1 Schedule Today Oct. 4 (TH) Functional Dependencies and Normalization. u Read Sections Project Part 1 due. Oct.
Functional Dependencies CS 186, Spring 2006, Lecture 21 R&G Chapter 19 Science is the knowledge of consequences, and dependence of one fact upon another.
©Silberschatz, Korth and Sudarshan7.1Database System Concepts Chapter 7: Relational Database Design First Normal Form Pitfalls in Relational Database Design.
Functional Dependencies Prof. Yin-Fu Huang CSIE, NYUST Chapter 11.
Introduction to Normalization CPSC 356 Database Ellen Walker Hiram College.
Relational Database Design by Relational Database Design by Dr.S.Sridhar, Ph.D.(JNUD), RACI(Paris, NICE), RMR(USA), RZFM(Germany) DIRECTOR ARUNAI ENGINEERING.
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.
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.
CS 564 Database Management Systems: Design and Implementation Discussion Session Friday, Sept 18, Apul Jain.
Revisit FDs & BCNF Normalization 1 Instructor: Mohamed Eltabakh
Final Exam Revision Instructor: Mohamed Eltabakh 1.
Minimum Cover of F. Minimal Cover for a Set of FDs Minimal cover G for a set of FDs F: –Closure of F = closure of G. –Right hand side of each FD in G.
Third Normal Form (3NF) Zaki Malik October 23, 2008.
Functional Dependencies R&G Chapter 19 Science is the knowledge of consequences, and dependence of one fact upon another. Thomas Hobbes ( )
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
1 Multivalued Dependencies Fourth Normal Form Reasoning About FD’s + MVD’s.
MIS 3053 Database Design And Applications The University Of Tulsa Professor: Akhilesh Bajaj Normal Forms Lecture 1 © Akhilesh Bajaj, 2000, 2002, 2003.
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
CS542 1 Schema Refinement Chapter 19 (part 1) Functional Dependencies.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 340 Introduction to Database Systems.
© 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.
Chapter 8 Relational Database Design. 2 Relational Database Design: Goals n Reduce data redundancy (undesirable replication of data values) n Minimize.
CSC 411/511: DBMS Design Dr. Nan Wang 1 Schema Refinement and Normal Forms Chapter 19.
Case tool Relational Database Schema Designer Cai Xinlei Tang Ning Xu Chen Zhang Yichuan CS4221 P06.
Formal definition of a key A key is a set of attributes A 1,..., A n such that for any other attribute B: A 1,..., A n  B A minimal key is a set of attributes.
CS 440 Database Management Systems
CS 440 Database Management Systems
CS422 Principles of Database Systems Normalization
Relational Database Design (Discussion Session)
CS422 Principles of Database Systems Normalization
CS 480: Database Systems Lecture 22 March 6, 2013.
How to test Whether Subschemes in BCNF??
Functional Dependencies and Normalization
CSCI 6315 Applied Database Systems – Exercise (4)
CSCI 4333 Database Design and Implementation – Exercise (4)
Some slides are from Dr. Sara Cohen
CSCI 4333 Database Design and Implementation – Exercise (4)
Computing Closure of F We could test for whether a relation scheme is in BCNF, if we could compute the closure of F. Closure of F can be computed using.
Quiz 2 Let R(A,B,C,D) be a relation schema with
CS4222 Principles of Database System
Presentation transcript:

CS 440 Database Management Systems Practice problems for normalization

Question 1: FD & key Consider a relation R(A,B,C,D,E) with FD's, S={AB  C, CD  E, C  A, C  D, D  B}: a) Determine all the keys of relation R. Do not list super keys that are not a minimal key. Solution: Keys: AB, AD, C To get the key AB, we can do the following: – From AB  C and C  D, we obtain AB  D. – From AB  C and AB  D, we obtain AB  CD. – From AB  CD and CD  E, we obtain AB  E.

Question 1 (Solution Contd..) To get the key AD, we can do the following: – From D  B, we can get AD  AB. – From AB, we can obtain the rest of the attributes. To get the key C, we can do the following: – From C  A and C  B, we obtained C  AB. – From AB, we can obtain the rest of the attributes.

Question 2: FD Consider a relation R(A, B, C, D, E, F) with the following set of FD’s : S:{ A  BC, CD  E, B  D, E  A, CF  B} a) Give an example of FD that follows from S and explain your answer. Solution: AB  D, D is in the closure of AB. Because A  B and B  D Thus AB  D is a valid FD that follows S.

Question 2(Solution Contd..) Consider a relation R(A, B, C, D, E, F) with the following set of FD’s : S:{ A  BC, CD  E, B  D, E  A, CF  B} b) Give an example of FD that does not follow from S and explain your answer. Solution: B  C, C is not in the closure of B. B doesn’t uniquely identify C accordance to S. So, B  C is not valid accordance to S.

Question 3: BCNF Consider relation R (A, B, C) with a set of FDs F={AB → C, C→A}. determine whether R is in BCNF. Solution: The keys are AB and BC. R is not in BCNF since left hand side of C→A is not a super key.

Question 4: BCNF Consider the relation schema R(A, B, C, D, E) with FD’s, A  BCDE, C  D, and CE  B. Decompose the relation till it follows BCNF. Solution: R is not in BCNF because CE  B and CE is not a super key. Decompose R: R1= {CEB}, R2={ACDE} R1 is in BCNF R2 is not in BCNF, because C  D and C is not a super key Decompose R2: R21= {C,D}, R22={A,C,E} R1,R21,R22 are in BCNF.

Question 5: BCNF Consider a relation R=(A,B,C,D,E) with the following functional dependencies, S= {BC  ADE, D  B}. a) Find all candidate keys. Solution: The keys are {B,C} and {C,D}. {B,C} is a key from BC  ADE. To get the key {C,D}: from D  B we get B, with B and C we have BC  ADE.

Question 5 (Contd..) Consider a relation R=(A,B,C,D,E) with the following functional dependencies, S= {BC  ADE,D  B}. b) Identify whether or not R is in BCNF. Solution: The relation is not BCNF because D is not a super key which violates BCNF.

Question 6: BCNF Consider a relation R = (A,B,C,D,E) with the following functional dependencies, S= {CE  D,D  B,C  A}. a) Find all candidate keys. Solution: The only key is {C,E} To get the key CE, we can do the following: – From CE  D and D  B, we obtain CE  B. – From CE  D and C  A, we obtain CE  AD.

Question 6 (Contd..) Consider a relation R = (A,B,C,D,E) with S = {CE  D,D  B,C  A}. b) If the relation is not in BCNF, decompose it until it becomes BCNF. Solution: Relation R is not in BCNF. Step 1: Decomposes R into R1=(A,C) and R2=(B,C,D,E). Resulting R1 is in BCNF. R2 is not. Step 2: Decompose R2 into, R21=(C,D,E) and R22=(B,D). Both relations are in BCNF.