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

C Questions

C Questions
C Questions

Note : All the programs are tested under Turbo C/C++ compilers.
It is assumed that,
Programs run under DOS environment, The underlying machine is an x86 system, Program is compiled using Turbo C/C++ compiler.
The program output may depend on the information based on this assumptions (for example sizeof(int) == 2 may be assumed).
Predict the output or error(s) for the following:

void main()
{
int const * p=5; printf("%d",++(*p));
}
Answer:
Compiler error: Cannot modify a constant value.
Explanation:
p is a pointer to a "constant integer". But we tried to change the value of the "constant integer".
main()
{
char s[ ]="man"; int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
Answer: mmmm
aaaa nnnn
Explanation

Zoho Interview | Set 1 (Advanced Programming Round)

Third Round: (Advanced Programming Round) Here they asked us to create a “Railway reservation system” and gave us 4 modules. The modules were:
    1. Booking
    2. Availability checking
    3. Cancellation
    4. Prepare chart
We were asked to create the modules for representing each data first and to continue with the implementation phase.

 My Solution :

#include<stdio.h>#include<conio.h>#include<stdlib.h>#include<string.h>#include<iostream.h>#include<time.h>#include<iomanip.h>#include<fstream.h>char f[10]="f";char s[10]="s";int addr,ad,flag,f1,d,m,i,amt;float tamt; class login {public:char id[100];char pass[100];char*password;void getid(){ cout<<"Enter your id:";gets(id); password=getpass("Enter the password:");strcpy(pass,password);}void displayid(){ cout<<"Id:";puts(id); cout<<"Password:";puts(pass);}}; class detail {public:in…

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