Skip to main content

GATE Questions-DBMS-Functional Dependency

Previous GATE questions with solutions on DBMS (Functional Dependency) - CS/IT

GATE-1999
1. Let R= (A, B, C, D, E, F) be a relation scheme with the following dependencies: C->F, E->A, EC->D, A->B. Which of the following is a key for R?
(a) CD             (b) EC           (c) AE            (d) AC

Ans: option (b)
Explanation:
Find the closure set of all the options give. If any closure covers all the attributes of the relation R then that is the key.
Algorithm to find Closure Set
Step1: Equate an attribute or attributes to X for which closure needs to be identified.
Step2: Take each FD (functional dependency) one by one and check whether the left side of FD is available in X, if yes then add the right side attributes to X if it is not available.
Step3: Repeat step 2 as many times as possible to cover all FD's.
Step4: After no more attributes can be added to X declare it as the closure set.

FDs: C->F, E->A, EC->D, A->B
Find closure set for CD.
X = CD
   = CDF {C->F}
No more attributes can be added to X. Hence closure set of CD = CDF

Find closure set for EC.
X = EC
   = ECF {C->F}
   = ECFA {E->A}
   = ECFAD {EC->D}
   = ECFADB {A->B}
Closure set of EC covers all the attributes of the relation R.

GATE-2000
2. Given the following relation instance.
-------
X  Y  Z
-------
1  4  2
1  5  3
1  6  3
3  2  2
------- 
Which of the following functional dependencies are satisfied by the instance?
(a) XY -> Z and Z -> Y (b) YZ -> X and Y -> Z
(c) YZ -> X and X -> Z (d) XZ -> Y and Y -> X

Ans: option (b)
Explanation:
Association among attributes is known as Functional Dependencies (FD). A FD X->Y require that the value of X uniquely determines the value of Y where X and Y are set of attributes.
For example,
Roll_No -> Name: the value of Roll_No uniquely determines the Name. 
Roll_No, Book_No -> Issue_Date : In the case of library, Roll_No and Book_No can determine the Issue_Date of a book.

In option (a), its given Z->Y, it means that the value of Z uniquely determines the value of Y. But here the value 2 of Z, gives two different values of Y i.e. 4 and 2. Therefore this FD is not satisfied by the instance.
In option (c), its given X->Z, it means that the value of X uniquely determines the value of Z. But here the value 1 of X, gives two different values of Z i.e. 2 and 3. Therefore this FD is not satisfied by the instance.
n option (d), its given Y->X, here the value of Y uniquely determines the value of X. Therefore this FD is satisfied by the instance. Now take FD XZ->Y, here (1,3) cannot uniquely determine the value of Y. (1,3) gives two values for Y i.e. 5 and 6. Therefore this FD (XZ->Y) is not satisfied by the instance.

GATE-2002
3. From the following instance of a relational schema R(A, B, C), we can conclude that:
----------
A  B C
----------
1 1 1
1 1   0
2 3   2
2   3   2
----------
(a) A functionally determines B and B functionally determines C
(b) A functionally determines B and B does not functionally determine C
(c) B does not functionally determine C
(d) A does not functionally determine B and B does not functionally determine C

Ans: option (b)
Explanation: 
Check the explanation of question 2.

GATE-2005
4. Consider a relation scheme R = (A, B, C, D, E, H) on which the following functional dependencies hold: {A–>B, BC–>D, E–>C, D–>A}. What are the candidate keys of R?
(a) AE, BE         (b) AE, BE, DE
(c) AEH, BEH, BCH (d) AEH, BEH, DEH

Ans: option (d)
Explanation:
As explained in question 1, if any closure includes all attributes of a table then it becomes the candidate key.
Closure of AEH = AEHB   {A->B}
               = AEHBC  {E->C}
               = AEHBCD {BC->D}

GATE-2005(IT)
5. In a schema with attributes A, B, C, D and E, following set of functional dependencies are given:
 A->B
 A->C
CD->E
 B->D
 E->A
Which of the following functional dependencies is NOT implied by the above set?
(a) CD->AC            (b) BD->CD         (c) BC->CD          (d) AC->BC

Ans: option (b)
Explanation:
For every options given, find the closure set of left side of each FD. If the closure set of left side contains the right side of the FD, then the particular FD is implied by the given set. 
Option (a): Closure set of CD = CDEAB. Therefore CD->AC can be derived from the given set of FDs.
Option (c): Closure set of BC = BCDEA. Therefore BC->CD can be derived from the given set of FDs.
Option (d): Closure set of AC = ACBDE. Therefore AC->BC can be derived from the given set of FDs.
Option (b): Closure set of BD = BD. Therefore BD->CD cannot be derived from the given set of FDs.


GATE-2006
6. The following functional dependencies are given:
 AB->CD, AF->D, DE->F, C->G , F->E, G->A
Which one of the following options is false?
(a)CF+ = {ACDEFG}                             (b)BG+ = {ABCDG}
(c)AF+ = {ACDEFG}                             (d)AB+ = {ABCDFG}

Ans: option(c)
Explanation:
As explained in question 1, find the closure set of each options.
Option (d) is also false. AB+ = {ABCDG}.

Comments

Popular posts from this blog

ORACLE 9i practice solutions

Created by BCL easyConverter SDK 3 (HTML Version)

Zoho Puzzle Questions With Answers

Measuring Time Logic Puzzle You are given with two ropes with variable width. However if we start burning both the ropes, they will burn at exactly same time i.e. an hour. The ropes are non-homogeneous in nature. You are asked to measure 45 minutes by using these two ropes.

How can you do it?

Please note that you can’t break the rope in half as it is being clearly stated that the ropes are non-homogeneous in nature.
Answer & Explanation Solution: 45 minutes

Explanation :
All you have to do is burn the first rope from both the ends and the second rope from one end only simultaneously. The first rope will burn in 30 minutes (half of an hour since we burned from both sides) while the other rope would have burnt half. At this moment, light the second rope from the other end as well. Where, the second rope would have taken half an hour more to burn completely, it will take just 15 minutes as we have lit it from the other end too.

Thus you have successfully calculated 30+15 = 45 minutes …

Hackerrank > SQL > Basic Select

Select
01-Select All
Given a City table, whose fields are described as +-------------+----------+ | Field       | Type     | +-------------+----------+ | ID          | int(11)  | | Name        | char(35) | | CountryCode | char(3)  | | District    | char(20) | | Population  | int(11)  | +-------------+----------+
write a query that will fetch all columns for every row in the table.

My Solution
SELECT*FROM city;
---------------------------------------------------------------------------------
02-Select by ID
Given a City table, whose fields are described as