15,944 views
9 votes
9 votes
a relation R(A,B,C,D,E,F,G,H)

and set of functional dependencies are {CH->G,A->BC,B->CFH,E->A,F->EG }

then how many possible super keys are present ?

4 Answers

Best answer
12 votes
12 votes

We know, P(A ⋃ B ⋃ C ⋃ D) = P(A) + P(B) + P(C) + P(D) - P(A∩B) - P(B∩C) - P(C∩D) - P(D∩A) + P(A∩B∩C) + P(B∩C∩A) + P(C∩D∩A) - P(A∩B∩C∩D)

Here candidate keys are (AD) , (BD) , (ED) , (FD)

No. of super keys 2n-(size of candidate key) [n=no. of keys]

Here 28-2 =26 ⨉ 4=256 [As 4 such candidate keys available]....................i

Now use set operation to eliminate duplicate key

Now by (AD) , (BD) , (ED), (FD) duplicate keys of 3 element dulpicate keys possible 6. those are (ABD),,(ADE) , (ADF), (EDB),(EDF), (BDF)

No more 3 element keys are possible.

So, super keys are 28-3 ⨉6 = 192...................................ii

Similarly 4 element keys are (ADEB) , (ADEF) , (EBDF) , (ADBF)

Now no of super keys are  28-4⨉4=64................................iii

Now 5 element key (ABDEF)

No. of super keys 28-5⨉1=8.........................iv

Now just putting it into formula of set 256 - 192 + 64 -8 =120

selected by
14 votes
14 votes

First finding out candidate keys.

D is not present at RHS of any FD. So, it must be present in any key.

AD -> BCDEFGH, hence AB is a candidate key.

Due to E -> A, ED is another candidate key.

F->E makes FD another candidate key and similarly B->F makes BD also a candidate key.

Thus we get {AD, ED, FD, BD} as candidate keys.

Now any superset of a candidate key is a super key.

In each of the above we can add any subset of the 6 remaining elements (excluding the 2 considered for the candidate key) and we get a superkey. No. of subsets of a 6 element set $=2^6 = 64$. And 4 times this should be $4 \times 64 = 256.$.

But in the above case for AD, we have considered the super key ADE and similarly for ED we have considered EDA. Similarly for {ADF, FDA} and {ADB, BDA}. Each of these would correspond to $2^5 = 32$ cases being repeatedly added (any combination of remaining 5 elements). Thus $3 \times 32 = 96$ subtractions needed. But we have done subtraction for the cases ADEF, ADEB, ADFB twice. So, have to add $3 \times 2^4 = 48.$ Here, we again do common addition for ADEFB and this requires subtraction of 8. 

Similarly we require $2 \times 32 $ subtractions and 16 additions for {EDF, FDE}, {EDB, BDE} and 32 subtractions for {FDB, BDF} giving 256 - 96 + 48 - 8 - 64 +16 - 32 = 120 possible super keys.

I'll give a better way :)


The question is an application of Inclusion-Exclusion principle. Here, the 4 candidate keys correspond to 4 sets each with 64 elements. Now, the set of all super keys will be (W = AD, X = ED, Y = FD, Z = BD)

$|W \cup X \cup Y \cup Z| = |W | + |X| + |Y| + |Z| - |W \cap X| - |W \cap Y| - |W \cap Z| - |X \cap Y| - |X \cap Z| - |Y \cap Z| + |W \cap X \cap Y| + |W \cap X \cap Z| + |W \cap Y \cap Z| + |X \cap Y \cap Z| - |W \cap X \cap Y \cap Z|$

Now, $|W \cap X| = |ADE| = 2^5 = 32$ 

Also, $ |W \cap X| =  |W \cap Y| =  |W \cap X| =  |X \cap Y| =  |X \cap Z| =  |Y \cap Z|$

$ |W \cap X \cap Y| = |ADEF| = 2^4 = 16. $

Also, $|W \cap X \cap Y| =|W \cap X \cap Z| =|W \cap Y \cap Z| =|X \cap Y \cap Z|$

$ |W \cap X \cap Y|= |ABDEF| = 8.$

So, $|W \cup X \cup Y \cup Z| = 4 \times 64 - 6 \times 32 + 4 \times 16 - 8 = 256 - 192 + 64 - 8 = 120.$


 

4 votes
4 votes

here no of candidate key are 4 which is (AD), (BD), (ED), (FD)

Then no of super key due to AD is 2^n-2 where n is no of attribute so 2^6

same no for BD ,ED,FD  so 4* (2^6)  and due to ABD,AED,AFD,BED,BFD,EFD IS - 6(2^5)

and due to ABED,AEFD,AEFD,ABFD is+4*(2^4)   and finally with ABEFD IS -(2^3)  SO total super keys are 

 4* (2^6)- 6(2^5)+4*(2^4)-(2^3)   is the answer  and such type question never be asked in gate they always intrested to find out the no of candidate key

edited by
–1 votes
–1 votes
I think n+1
Answer:

Related questions

4 votes
4 votes
1 answer
4
Akash Kanase asked Jan 15, 2016
734 views
I think here even with Ph is removed from table we still get 12 Super keys. Because Salary & One of CK must be there.