This action might not be possible to undo. Are you sure you want to continue?

# Normalization Questions and Answers

Database Systems, CSCI 4380-01 Sibel Adalı October 28, 2002

Question 1 Suppose you are given a relation R = (A, B, C, D, E) with the following functional dependencies: {CE → D, D → B, C → A}. a. Find all candidate keys. b. Identify the best normal form that R satisﬁes (1NF, 2NF, 3NF, or BCNF). c. If the relation is not in BCNF, decompose it until it becomes BCNF. At each step, identify a new relation, decompose and re-compute the keys and the normal forms they satisfy. Answer. a. The only key is {C, E} b. The relation is in 1NF c. Decompose into R1=(A,C) and R2=(B,C,D,E). R1 is in BCNF, R2 is in 2NF. Decompose R2 into, R21=(C,D,E) and R22=(B,D). Both relations are in BCNF.

Question 2 Suppose you are given a relation R=(A,B,C,D,E) with the following functional dependencies: {BC → ADE, D → B}. a. Find all candidate keys. b. Identify the best normal form that R satisﬁes (1NF, 2NF, 3NF, or BCNF). c. If the relation is not in BCNF, decompose it until it becomes BCNF. At each step, identify a new relation, decompose and re-compute the keys and the normal forms they satisfy. Answer. a. The keys are {B, C} and {C, D} b. The relation is in 3NF c. It cannot be put into BCNF, even if I remove D and put into a relation of the form (B,C,D) (I need C for the functional dependency), the resulting relation would not be in BCNF.

Question 3 Suppose you are given a relation R=(A,B,C,D,E) with the following functional dependencies: BD → E, A → C. a. Show that the decomposition into R1=(A,B,C) and R2=(D,E) is lossy. You can show using any method. My suggestion is to show how spurious tuples result from this decomposition with respect to the table below: A 1 1 B 2 8 C 3 3 D 4 4 E 5 4 1

C. show all dependencies that violate it. AB → C and DC → A are preserved in the ﬁrst relation.B.C. D} and {B. Hence. a. What are the keys of this relation? b. No dependency contains a superkey on its left side. Is the decomposition (A.C. explain why by showing one violation. a. F = {AB → C. b.D) (B.C. a. However.E. explain brieﬂy. show all dependencies that violate it. b. a. explain why by showing one violation.B. DC → E and E → F are preserved in the second relation. a lossy decomposition of the form (A. Is this relation is in BCNF? If not. If we were to decompose the relations into: A 1 1 B 2 8 C 3 3 D 4 4 E 5 4 and then join the two (in this case with a cartesian product). Is this relation in BCNF? If not. C. c.F). No. 2 . D}.F) a dependency preserving decomposition? If not.C. Is this relation in BCNF? If not. E → F }.B. AB → D. DC → AE. BC → E}. (C. all functional dependencies are actually violating this. F = {AB → C. c.D.E. Question 5 You are given the below functional dependencies for relation R(A.C.B. Yes.C).D.b. Is the decomposition (A. D → A. BC → D. explain brieﬂy.D. Answer. B. Find a single dependency from a single attribute X to another attribute Y such that when you add the dependency X → Y to the above dependencies. this decomposition is lossy. Answer. Is this relation in 3NF? If not. we would get: A 1 1 1 1 B 2 8 2 8 C 3 3 3 3 D 4 4 4 4 E 5 5 4 4 Tuples 2 and 3 are not in the original relation.D) (B. Question 4 You are given the following set of functional dependencies for a relation R(A.D.E). This decomposition cannot be made lossless. What are the keys of this relation? {A.E.E) can be made lossless by adding an FD B → C. the decomposition in part a is no longer lossy. b.B. The problem is there is no longer a way to make sure BD → E holds across two relations since they do not share any attributes.F) a dependency preserving decomposition? If not.D.

You do not have to list all the cases you test/consider for the algorithm.D. Suppose we decompose the above relation into the following two relations: R1(A. b.C.C. write down the functional dependencies that fall within that relation (you can decompose a dependency of the form AD → BF into two i.B. AD → B and AD → F when computing this).D.F. c.D) and R2(A. BC → E (given) ABC → AE by the augmentation rule. Find the minimal cover for the above set of functional dependencies using the algorithm described in class. C}. CD → EGC. 3 . show how using the Amstrong’s Axioms given in the book (p. BD → F.E). a. B}. then this decomposition is lossy. Keys for the relation: {A.E) R2(A. c. R1 A ’a’ ’e’ ’a’ ’b’ R2 A ’a’ ’e’ ’a’ ’b’ R1 A ’a’ ’e’ ’a’ ’b’ ’a’ ’a’ R2 B 122 236 199 213 122 199 C 1 4 1 2 1 1 D ’s1’ ’e2’ ’b5’ ’z8’ ’s1’ ’b5’ E ’a’ ’b’ ’c’ ’d’ ’a’ ’c’ B 122 236 199 213 C 1 4 1 2 D ’s1’ ’e2’ ’b5’ ’z8’ C 1 4 1 2 E ’a’ ’b’ ’c’ ’d’ Since the last two rows are not in the original relation. ﬁnd the keys for this relation.G). {B. but be succinct. a.B. D}. For each relation. {B.F.c. Is it in BCNF? Explain your reasoning. E → D. Is the following dependency implied by the above set of dependencies? If so.G) Use the functional dependencies in the minimal cover. A is part of a key. Not in BCNF since D → A does have a superkey on the left hand side.D. This question is independent of Question 2 above.e.C. You do not know the functional dependencies for this relation. 362-363): ABC → AE Answer. Give suﬃcient detail to show your reasoning. Using the functional dependencies that you computed in step a.C. F → C.B. b. Answer. F = {AD → BF.E). A ’a’ ’e’ ’a’ ’b’ B 122 236 199 213 C 1 4 1 2 D ’s1’ ’e2’ ’b5’ ’z8’ E ’a’ ’b’ ’c’ ’d’ Suppose this relation is decomposed into the following two tables: R1(A. Is this decomposition lossless? Explain your reasoning.C. Question 7 You are given the below set of functional dependencies for a relation R(A.E. In 3NF since in D → A. Show all steps where you make changes to the above set in detail.D.B. D → F }. Question 6 You are given the table below for a relation R(A.

8).C. C.D.Using these functional dependencies. Question 9 Consider relation R(X. this is a lossless decomposition. Relation R currently has three tuples: (6. F+)? Hint. F → C. Keys: {A. and BD → F . CD → E.B. CD → C. Let F’ be obtained by replacing CDF → B with CD → B. head(R1) ∩ head(R2) = {A. the dependency F → C is not preserved. removeCD → C. CD → G. B. BD → F. Counterexample ABD → E and ABD is not a superkey.C. Counterexample ABD → E. 6. Can the set F be simpliﬁed (by removing functional dependencies or by removing attributes from the left hand side of functional dependencies) without changing the closure of F (i. {A. Keys: {A.D R2: AD → ADF G is true since this is implied by D → GF as follows: AD → AD inclusion rule. Y. a. Which of the following three functional dependencies can you infer do not hold for relation R? Explain your answer. C} and {A. {AD → B. D → F. R1(A. D → EGF. and ABD is not a superkey and E is not prime attribute (part of a key). Hence. E → D. c. 4. F → C. 2). Hence. F → C. c. Do any of them apply to this functional dependency? Answer. E → D}. AD → F . B. remove D from CD → E and CD → G {AD → B. 4. D → G. Not functional dependency preserving.E) Dependencies: AD → B. D} b. CD → E. D → F. D → F } Step 2. D}. E → D} Step 3. Y →X 4 . It is not in 3NF.F.e. D. 8) and (6. Not in BCNF since the last three functional dependencies do not have a superkey on the left hand side. c. since D → GF . According to F and F’. Explain your reasoning. determine if this decomposition is lossless and/or dependency preserving. ABD → E. a. {AD → B. AD → ADGF . b. Find all keys of R based on these functional dependencies. Consider the steps of the minimal cover algorithm. AD → F. D → E. BF → D}. F }. we can remove F from this functional dependency without changing the meaning of the system. Is this relation in Boyce-Codd Normal Form? Is it 3NF? Explain your answers. D → E. CD → G.G) Dependencies: D → GF .D.E. CDF → B. (6.B. Z). a. E → D} Finally recombine {AD → B. CD+ = {C. Answers. E}. Question 8 You are given the following set F of functional dependencies for a relation R(A. F → C. It is not in BCNF. b.D. use set accumulation rule. D} R1: AD → ABCDE is not true since C is not implied by A.F): F = {ABC → D. E → D R2(A. Step 1. CD → F.

W } b. Y. W. ADDRESS. W Z → Y. V W → X}. but the rest do not hold. W Z → XY. b)Is your decomposition in part a) also in Boyce Codd Normal Form? Explain your answer. DNUMBER. {V. BDATE. Possible keys: {Y }. Y → X. since W Z → Y and Y → X Don’t need Y → W . X → V. The only attribute in common is X and it functionally determines all the attributes in R2. Step 1: X → W. Answer. R1(V. where G is a minimal cover: a) Decompose R into a set of relations in Third Normal Form. Question 11 Given relation R(W. Y → Z Step 2: Don’t need W Z → X. Y. DNAME. Step 4: {X → W W Z → Y. b) Show the closure for attribute X given the functional dependencies above. Yes it is lossless. The ﬁrst and third tuples both have 6 and 4 for X and Y but diﬀerent values for Z. c) Suppose that relation R is decomposed into two relations. Question 13 Consider a relation named EMP DEPT with attributes: ENAME. a. W. R2=(X. Y → Z. and DMGRSSN. Z}. W Z → X. Y.Yes. Z). Z) and set of functional dependencies F = {X → W. all three relations satisfy the deﬁnition of BCNF. V. Answer. Can’t eliminate W or Z. The second and third tuples both have 8 for Z but diﬀerent values of Y. Y → W XZ}. The ﬁrst functional dependency holds. In each of the three relations. {X. Hence. W). {W. XW → Y }. X + = {X. Z). X. Y → XZ} is the minimal cover Question 12 Given relation R(W. since Y → X and X → W This leaves {X → W W Z → Y. So nothing is eliminated. X → Y. X) and R2(X. {X. Y. Z) and set of functional dependencies G = {Z → W. Y → XZ. X. Question 10 Consider the relation R(V. Y.Z→Y XY → Z Answer. X. Z) with functional dependencies {Z → Y. a) List the possible keys for relation R based on the functional dependencies above. X} R1=(Z. Consider also the set G of functional dependencies for EMP DEPT: 5 . Is this decomposition a lossless decomposition? Explain your answer. Y. W }. R3=(X. Y → X. To be lossless the attributes in common between the two relations must functionally determine all the attributes in one of the two relations. Y → Z} Step 3: Only need to consider W Z → Y . the left side of the funcational dependencies that apply are superkeys for the relation. Answer. W) b. Y → W. Compute the minimal cover for F. Y. SSN. Z} c. a.

a) Calculate the closures SSN+ and DNAME+ with respect to G.employee-ssn point to EMPLOYEE. This leads to the possibility of an inconsistency in the database if they are not all changed. quantity) ITEMS(item-id. item-name. WORKS-IN. last-name. 6 . ssn → f irst − name. In BCNF..supervisor-ssn and WORKS-IN. address → ssn}.dept-no. item-id. INVENTORY. ssn → date − joined. Answer. address. Question 14 You are given the following functional dependencies for the ”EMPLOYEE” relation.e. e) If you delete the last employee for a department. name. BDAT E. DM GRSSN } DN AM E + = {DN AM E} b) It is minimal. DN U M BER. ﬁnd a minimal set of functional dependencies that is equivalent to G. b) Is the set of functional dependences G minimal? If not. ssn → last − name.G = {SSN → EN AM E BDAT E ADDRESS DN U M BER. c) List an update anomaly that can occur for relation EMP DEPT.item-id. d) You cannot enter data about a department until you have employees for the department. type) Foreign keys: 1. when the department manager changes this reference must be changed multiple places.ssn. you lose all information about the department. {ssn → supervisor − ssn. DN U M BER → DN AM E. a) SSN + = {SSN. 2. manager-ssn) WORKS-IN(employee-ssn. Dmgrssn). dept-no) INVENTORY(dept-no. ssn → address. e) List a deletion anomaly that can occur for relation EMP DEPT. d) List an insertion anomaly that can occur for relation EMP DEPT. first-name. date-joined. EMPLOYEE. DM GRSSM }.item-id points to ITEMS. EN AM E. 3. Explain whether the relation ”EMPLOYEE” is BCNF and 3NF? Database: EMPLOYEE(ssn. ADDRESS. Answer. since ssn and address are both keys of EMPLOYEE.dept-no and INVENTORY. DN AM E. c) Since every member of a department has a reference to the manager of that department (i. supervisor-ssn) DEPARTMENT(dept-no.dept-no point to DEPARTMENT.