FOR FREE MATERIALS

Find Candidate Key Examples and GATE question

 

Before seeing the chapter please follow the previous chapter: Find Prime and Non-Prime Attribute,  Find Super and Candidate Key from Attribute Closer

 

Q: Gate 2005

What are Candidate Keys?

1. AE, CE

2. AE, BE, DE

3. AEH, BEH, DEH

4. AEH, BEH, BCH

 

Solution:

AE is common in every option

So, we can calculate the closure of AE

(AEH) is Super Key (SK) and Candidate Key (CKalso

CK = {AEH}, PA = {A, E, H}

 

We can find A from D → A

So, DEH is SK and CK

CK = {AEH, DEH}, PA = {A, E, H, D}

 

Looking for PA at FDs find BC → D

But it is a SK but not CK because it is not minimal reason is from we can derive 

(E → C). 

 

So, what is the minimum?

So, option 3 is correct.

 

Question:

Calculate the number of Candidate Key and Prime Attribute.

 

Solution:

but from FDs it is clear that from any FD we can’t find E. we can do one thing.

AE = ABCDE   [Augmented both side by E]

 

So, AE is SK and CK also

 

CK = {AE}, PA = {A, E}

 

Looking for and E as Prime Attribute (PA) at any FDs of the left-hand side,

 

So, ED is SK and CK

CK = {EA, ED}, PA = {A, E, D}

 

So, EC is SK and CK

CK = {EA, ED, EC}, PA = {A, E, D, C}

 

Again,

So, EB is SK and CK

CK = {EA, ED, EC, EB}, PA = {A, E, D, C, B}

So, CK = {AE, DE, CE, BE}, PA = {A, E, D, C, B}, NPA = ɸ = { }

 

Question:

Given Relation R (ABCD) and FDs {AB → C, C → D, CE → F, F → G}. 

Find out Candidate Key.

 

Solution:

Important:

One thing is very clear from FDs that CE → F, F → G but E, F, G attributes are not present in the given relation R (ABCD). So, we can delete it.

 

Candidate Key (CK) = {AB}, Primary Key (PA) = {A, B}

 

So, we can calculate valid FDs by using the transitive rule.

 

So, if given FDs are invalid, so we derive valid FDs from invalid ones if possible.