It is very helpful in learning all the basics concepts of DBMS starting from Introduction: An Overview of Database Management System to Data Modeling using the Entity-Relationship Model, PL/SQL, Transaction Processing Concept, and Concurrency Control Techniques plus important numerals in exam point of view can be learned.
24. SOLUTION ASSIGNMENT - 2
Department: Department of Computer Engineering & Applications
Subject Name & Code: Database Management System (CSE 3003)
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 satisfies (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.
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 satisfies (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.
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.
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, the decomposition in part a is no longer
lossy.
Answer:
a. intersection of R1 and R2 is ф hence this decomposition cannot be shown as lossless hence it
is lossy.
b. This decomposition cannot be made lossless. 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. However, a lossy
decomposition of the form (A,B,C), (C,D,E) can be made lossless by adding an FD B → C.
4. You are given the following set of functional dependencies for a relation R(A,B,C,D,E,F),
F = {AB → C,DC → AE,E → F}.
a. What are the keys of this relation?
b. Is this relation in BCNF? If not, explain why by showing one violation.
25. c. Is the decomposition (A,B,C,D) (B,C,D,E,F) a dependency preserving decomposition? If not,
explain briefly.
Answer.
a. What are the keys of this relation?
{A,B,D} and {B,C,D}.
b. Is this relation in BCNF? If not, explain why by showing one violation.
No, all functional dependencies are actually violating this. No dependency contains a superkey
on its left side.
c. Is the decomposition (A,B,C,D) (B,C,D,E,F) a dependency preserving decomposition? If not,
explain briefly.
Yes, AB → C and DC → A are preserved in the first relation. DC → E and E → F are preserved
in the second relation.
5. You are given the below functional dependencies for relation R(A,B,C,D,E), F =
{AB → C,AB → D,D → A,BC → D,BC → E}.
a. Is this relation is in BCNF? If not, show all dependencies that violate it.
b. Is this relation in 3NF? If not, show all dependencies that violate it.
c. Is the following dependency implied by the above set of dependencies? If so, show how using
the Amstrong’s Axioms: ABC → AE
Answer:
Keys for the relation: {A,B}, {B,D}, {B,C}.
a. Not in BCNF since D → A does have a super key on the left hand side.
b. In 3NF since in D → A, A is part of a key.
c. BC → E (given)
ABC → AE by the augmentation rule.
6. You are given the below set of functional dependencies for a relation R(A,B,C,D,E,F,G),
F = {AD → BF,CD → EGC,BD → F,E → D, F → C,D → F}.
a. Find the minimal cover for the above set of functional dependencies
b. Using the functional dependencies that you computed in step a, find the keys for this relation.
Is it in BCNF? Explain your reasoning.
c. Suppose we decompose the above relation into the following two relations:
R1(A,B,C,D,E) R2(A,D,F,G)
Use the functional dependencies in the minimal cover. For each relation, write down the
functional dependencies that fall within that relation
(you can decompose a dependency of the form AD → BF into two i.e. AD → B and AD → F
when computing this).
Answers.
a.
Step 1.
{AD → B,AD → F,CD → E,CD → G,CD → C,BD → F,E → D, F → C,D → F}
Step 2. removeCD → C, AD → F, and BD → F.
{AD → B,CD → E,CD → G, F → C,D → F,E → D}
Step 3. remove D from CD → E and CD → G
{AD → B,D → E,D → G, F → C,D → F,E → D}
Finally recombine
{AD → B,D → EGF, F → C,E → D}.
26. b. Keys: {A,D}, {A,E}. Not in BCNF since the last three functional dependencies do not have a
superkey on the left hand side.
c. R1(A,B,C,D,E) Dependencies: AD → B,D → E,E → D R2(A,D,F,G) Dependencies: D →
GF.
Not functional dependency preserving, the dependency F → C is not preserved.
head(R1) head(R2) = {A,D}
R1: AD → ABCDE is not true since C is not implied by A,D
R2: AD → ADFG is true since this is implied by D → GF as follows:
AD → AD inclusion rule, since D → GF, use set accumulation rule, AD → ADGF. Hence, this
is a lossless decomposition.
7. You are given the following set F of functional dependencies for a relation R(A,B,C,D,E,F):
F = {ABC → D,ABD → E,CD → F,CDF → B,BF → D}.
a. Find all keys of R based on these functional dependencies.
b. Is this relation in Boyce-Codd Normal Form? Is it 3NF? Explain your answers.
c. Can the set F be simplified (by removing functional dependencies or by removing attributes
from the left hand side of functional dependencies) without changing the closure of F (i.e. F+)?
Hint. Consider the steps of the minimal cover algorithm. Do any of them apply to this functional
dependency?
Answer.
a. Keys: {A,B,C} and {A,C,D}
b. It is not in BCNF. Counterexample ABD → E and ABD is not a superkey.
It is not in 3NF. Counterexample ABD → E, and ABD is not a superkey and E is not prime
attribute (part of a key).
c. Let F’ be obtained by replacing CDF → B with CD → B.
According to F and F’, CD+ = {C, D, B, F}. Hence, we can remove F from this functional
dependency without changing the meaning of the system.
8. Consider the relation R(V, W, X, Y, Z) with functional dependencies {Z → Y, Y → Z,X →
Y,X → V, VW → X}.
a) List the possible keys for relation R based on the functional dependencies above.
b) Show the closure for attribute X given the functional dependencies above.
c) Suppose that relation R is decomposed into two relations, R1(V, W, X) and R2(X, Y, Z). Is
this decomposition a lossless decomposition? Explain your answer.
Answer.
a. {V,W}, {X,W}
b. X+ = {X, V, Y,Z}
c. Yes it is lossless. To be lossless the attributes in common between the two relations must
functionally determine all the attributes in one of the two relations. The only attribute in common
is X and it functionally determines all the attributes in R2.
9. Given relation R(W, X, Y, Z) and set of functional dependencies F = {X → W,WZ → XY, Y
→ WXZ}. Compute the minimal cover for F.
Answer.
Step 1: X → W,WZ → X,WZ → Y, Y → W, Y → X, Y → Z
Step 2: Don’t need WZ → X, since WZ → Y and Y → X
Don’t need Y → W, since Y → X and X → W
This leaves {X → WWZ → Y, Y → X, Y → Z}
Step 3: Only need to consider WZ → Y . Can’t eliminate W or Z. So nothing is eliminated.
27. Step 4: {X → WWZ → Y, Y → XZ} is the minimal cover
10. Given relation R(W, X, Y, Z) and set of functional dependencies G = {Z → W, Y → XZ,XW
→ Y }, where G is a minimal cover:
a) Decompose R into a set of relations in Third Normal Form.
b)Is your decomposition in part a) also in Boyce Codd Normal Form? Explain your answer.
Answer.
a. Possible keys: {Y }, {X,Z}, {W,X}
R1=(Z, W), R2=(X, Y, Z), R3=(X, Y, W)
b.Yes. In each of the three relations, the left side of the funcational dependencies that apply are
superkeys for the relation. Hence, all three relations satisfy the definition of BCNF.
11. Find 3NF decomposition of the following relational schema:
R = {Faculty, Dean, Dept, Chairperson, Professor, Rank, Student}
with the set of functional dependencies,
F = {Faculty → Dean, Dept → Chairperson, Professor → {Rank, Chairperson}, Dept → Faculty,
Student → {Dept, Faculty, Dean}, Dean→ Faculty, {Professor, Rank} → {Dept, Faculty}}
Answer: Solution already provided.
12. Consider the given relation EMP_DEPT (ENAME, SSN, BDATE, ADD, DNO, DNAME,
DMGRSSN) with the set G of the function dependencies:
G = {(SSN →ENAME, BDATE, DNO), (ENAME→ ADD), (DNO →DNAME, DMGRSSN)}
Find the key of the relation with respect to G and normalize the relation up to 3NF.
13. Consider the following functional dependencies in a database.
Date_of_Birth->Age, Age->Eligibility, Name->Roll_number, Roll_number->Name,
Course_number->Course_name, Course_number->Instructor, (Roll_number,Course_number)-
>Grade
What normal form does the relation (Roll_number, Name, Date_of_birth, Age) follow? Give
reasons for your answer.
Answer: The above schema is in 1NF since the key of schema (Roll_number, Name, Date_of_birth,
Age) is either of the two: (Roll_number, Date_of_birth) or (Name, Date_of_birth) but since
Date_of_Birth->Age is a partial dependency, the schema is not in 2NF hence it is in 1NF.
32. Shalabh Chaudhary [GLAU]
TIME : 30 mins DBMS QUIZ TOTAL MARKS : 25
NAME: SHALABH CHAUDHARY SEM: III
1. Which normal form is considered adequate for normal relational database design?
(a) 2NF (b) 5NF (c) 4NF (d) 3NF
2. Which of the following is TRUE?
(a) Every relation in 2NF is also in BCNF
(b) A relation R is in 3NF if every non-prime attribute of R is fully functionally dependent on every key of R
(c) Every relation in BCNF is also in 3NF
(d) No relation can be in both BCNF and 3NF
3.The employee information in a company is stored in the relation
Employee (name, sex, salary, deptName)
Consider the following SQL query
Select deptName From Employee Where sex = ‘M’ Group by deptName Having avg(salary) > (select avg (salary) from
Employee)
It returns the names of the department in which
(a) the average salary is more than the average salary in the company
(b) the average salary of male employees is more than the average salary of all male employees in the company
(c) the average salary of male employees is more than the average salary of
employees in the same department.
(d) the average salary of male employees is more than the average salary in the company
4. Assume that, in the suppliers relation above, each supplier and each street within a city has a unique name, and (sname, city)
forms a candidate key. No other functional dependencies are implied other than those implied by primary and candidate keys.
Which one of the following is TRUE about the above schema?
(a) The schema is in BCNF (b) The schema is in 3NF but not in BCNF
(c) The schema is in 2NF but not in 3NF (d) The schema is not in 2NF
5. Relation R has eight attributes ABCDEFGH. Fields of R contain only atomic values. F={CH→G, A→BC, B→CFH, E→A,
F→EG} is a set of functional dependencies (FDs) so that F + is exactly the set of FDs that hold for R.
How many candidate keys does the relation R have?
(a) 3 (b) 4 (c) 5 (d) 6
6. The relation R is
(a) in 1NF, but not in 2NF. (b) in 2NF, but not in 3NF. (c) in 3NF, but not in BCNF. (d) in BCNF.
7. The ................. is related to the concept of multi-valued dependency.
A) fourth normal form B) boyce codd normal form C) fifth normal form D) third normal form
8. A table is in BCNF if it is in 3NF and if every determinant is a ............... key.
A) dependent B) normal C) candidate D) Both B & C
9. A table is in 3NF if it is in 2NF and if it has no ......................
A) functional dependencies B) transitive dependencies
C) trivial functional dependency D) multivalued dependencies
10. Consider a relation with 3 attributes. How many maximum candidate keys could be atmost at the same time?
A. 2 B. 3 C. 4 D. 5
11. Let F = {AB-> C, AC-> B, B->D, BC->A} is set of FD of R(A,B,C,D). How many no of functional dependencies can you
get in the minimal cover of F?
A. 3 B. 4 C. 5 D. 6
12. Consider a relation R(ABCD) with FD's {A-> D, B ->D, D->BC} which is decomposed into R1(AB) and R2(BCD).
Which of the following is true?
A. Lossless join and dependency preserving decomposition B. Lossless join but not dependency preserving decomposition
33. Shalabh Chaudhary [GLAU]
C. Lossy join and dependency preserving decomposition D. Lossy join and not dependency preserving decomposition
13. Consider a relation R(ABCDE) with FD's {A->D,B->C,D->E,CE->B}. If we project R onto schema(ABC), what is true
about the keys of ABC?
A.Only A is the key B. Only AB is the key C. Only AB,AC are keys D. Only AB, BC, AC keys
14. A relation R(ABCD) has FD's F = {A->C, B->D}. How many minimal no of relational tables require lossless join and
dependency preserving BCNF decomposition?
A. 2 B. 3 C. 4 D. 5
15. Consider a relation R(ABCDE) with FD's F = {A->BC,C->D,B->E,A->E,B->A}. Which of the following is true regarding
R?
A. BC is superkey but not candidate key B. AC is candidate key so also superkey
C. There is only one candidate key of R D. None of these.
16. A relation R(ABCD) with F ={AB->C,C->D,D->C,A->B} is in
A. 1NF but not in 2NF B. 2NF but not in 3NF C. 3NF but not in BCNF D. BCNF
17. Consider a relation R(ABCDEFG) with F = {A->B,B->C,C->D,D->E,E->F,F->A}. Find the no of candidate keys?
A. 1 B. 3 C. 4 D. 6
18. Find the highest normal form of R?
A. 1NF B.2NF C. 3NF D. BCNF
19. For which of the following set of FD's, the relation R(ABCDE) is in 3NF but not in BCNF.
I. AB->CD, B->E,AC->BD II. A->B,BC->E,ED->A III. A->B,B->C,C->D,D->E,E->A IV. AB->CD,AC->BED,D->A
A. I,II,III,IV B. II,III C. II only D. II,IV
20. Consider a relation R(ABCD) with functional dependency as A->B,AB->C,BC->D. Find the minimal cover.
A. A->B,B->D B. AB->C,C->D C. A->B,A->C,BC->D D. A->D
21. Consider a relation R(ABCDE) with FD's {A->B,B->C,D->E}. Find the next higher normal form decomposition set for R?
A. D={R1(AB), R2(BC), R3(DE)} B. {R1(ABC),R2(CD),R3(DE)}
C. D={R1(ABC), R2(CDE)} D. D={R1(AB), R2(BC), R3(DE)}
22. Given R(ABCDE) with FD's AB->C,DE->C,B->D. Indicate all 3NF violations?
A. AB->C,DE->C B. AB->C,B->D C. AB->C,DE->C and B->D D. None of these
23. 14. A relation R(ABCD) has FD's F = {A->C, B->D}. Find the highest normal form?
A. 1NF B.2NF C. 3NF D. BCNF
24. Consider a relation R(ABCDE) with FD's {A->D,B->C,D->E,CE->B}. Find the highest normal form?
A. 1NF B.2NF C. 3NF D. BCNF
25. Consider relation R(ABCD) as follows:
A B C D
a b z 1
e b r 1
a d z 1
e d r 1
a f z 2
e f r 2
Find the total no of functional dependencies possible?(Ignore self dependencies such as A->A or B->B or AB->AB)
A.10 B.15 C. 12 D. 9