CS 440 Database Management Systems

Slides:



Advertisements
Similar presentations
Schema Refinement: Normal Forms
Advertisements

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.
CS Algorithm : Decomposition into 3NF  Obviously, the algorithm for lossless join decomp into BCNF can be used to obtain a lossless join decomp.
Classroom Exercise: Normalization
Normalization DB Tuning CS186 Final Review Session.
1 CMSC424, Spring 2005 CMSC424: Database Design Lecture 9.
1 Triggers: Correction. 2 Mutating Tables (Explanation) The problems with mutating tables are mainly with FOR EACH ROW triggers STATEMENT triggers can.
Normal Forms1. 2 The Problems of Redundancy Redundancy is at the root of several problems associated with relational schemas: Wastes storage Causes problems.
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
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.
CHAPTER 19 SCHEMA, REFINEMENT AND NORMAL FORMS
Rensselaer Polytechnic Institute CSCI-4380 – Database Systems David Goldschmidt, Ph.D.
Section 3 CSE 444 Introduction to Databases. Announcements Project 1 was due yesterday (10/14/2009) Homework 1 was released, due 10/28/2009.
CS542 1 Schema Refinement Chapter 19 (part 1) Functional Dependencies.
© 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.
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.
Functional Dependencies and Normalization 1 Instructor: Mohamed Eltabakh Part 2.
Relational Database Schema Designer Using Bernstein’s Algorithm
CS 440 Database Management Systems
CS422 Principles of Database Systems Normalization
Schedule Today: Next After that Normal Forms. Section 3.6.
Relational Database Design (Discussion Session)
Schema Refinement and Normal Forms
Relationship among the Three sides of a Triangle
CS411 Database Systems 08: Midterm Review Kazuhiro Minami 1.
Problem Axiom of addition:
Normalization First Normal Form (1NF) Boyce-Codd Normal Form (BCNF)
CS422 Principles of Database Systems Normalization
CS 480: Database Systems Lecture 22 March 6, 2013.
Normalization Algorithm
Problems in Designing Schema
تصنيف التفاعلات الكيميائية
Functional Dependencies and Normalization
CSCI 4333 Database Design and Implementation – Exercise (3)
Functional Dependencies and Normalization
How to test Whether Subschemes in BCNF??
Exercise R(A,B,C,D) with FD’s ABC, CD, and DA
Functional Dependencies and Normalization
Relational Data Base Design in Practice
CSCI 6315 Applied Database Systems – Exercise (4)
Fractional Factorial Design
Normalization Part II cs3431.
Chapter 15 Basics of Functional Dependencies and Normalization for Relational Databases.
CPSC-310 Database Systems
CSCI 4333 Database Design and Implementation – Exercise (4)
Lecture 8: Database Design
Normalization cs3431.
Some slides are from Dr. Sara Cohen
Instructor: Mohamed Eltabakh
CSCI 4333 Database Design and Implementation – Exercise (4)
Relational Database Design
Chapter 19 (part 1) Functional Dependencies
Instructor: Mohamed Eltabakh
Multivalued Dependencies
CSC 453 Database Systems Lecture
Design matrix Run A B C D E
Quiz 2 Let R(A,B,C,D) be a relation schema with
CSCI 6315 Applied Database Systems – Exercise (5)
Quizzes on FD and NF Chapter 19
CS4222 Principles of Database System
Design Theory for Relational Databases
Presentation transcript:

CS 440 Database Management Systems practice problems for constraints and schema design

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.

Question 1: Solution Consider a relation R(A,B,C,D,E) with FD's, S={AB  C, CD  E, C A, C  D, D  B}: 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. 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.

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.

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, cont’d) 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.

Question 2 (solution, cont’d) 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.

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 .

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.

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 cont’d 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.

Question 5 cont’d 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.

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 ,cont’d Consider a relation R = (A,B,C,D,E) with the following functional dependencies, S= {CE  D,D  B,C  A}. b) If the relation is not in BCNF, decompose it until it becomes BCNF.

Question 6 ,cont’d Consider a relation R = (A,B,C,D,E) with the following functional dependencies, 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.