# Find Candidate Keys by looking to Functional Dependencies

I'm studying Database Design and I am in trouble with the Candidate Keys and the Functional Dependencies.

I have these Functional Dependences:

B → CEF

B → DG

GA → B

My idea is: Since GA is the only one attribute that is not functionally determined by anyone, then, by using Armstrong's Axioms, I see that GA determines all attribute of the Schema S.

So there is only one Candidate Key: GA.

Am I right? Thanks in advance.

• You have `B -> G` so G is determined by B. Jan 17, 2017 at 16:30
• I have B -> DG, does this means: B -> G? And if yes, which is the candidate key? Jan 17, 2017 at 17:09
• Yes, B -> DG means B -> D and B -> G. And vice versa. As for candidate keys, I'll leave that to you (or someone else). For something to be a candidate key, it has to appear at the left side of at least one dependency (and that is not enough in many cases). So, what does this tell you about the candidate keys? What are the possible options? Jan 17, 2017 at 19:20
• You ask whether you're right, but your justification looks nothing like any process that you have been given for determining CKs. (You say that you start something unexplained using Armstrong's axioms from GA that gives it to be a superkey (determines all attributes) but you don't show that it's a CK or that it's the only CK.) Find an algorithm and all necessary definitions in a reference you have been given, then follow it exactly. If you get stuck, explain all steps to that point. PS Are A-G "all the attributes" of the schema? Or only the ones in the given FDs? Jan 21, 2017 at 7:07

The relation with the above functional dependencies has two different candidate keys: B and G.

You can verify this if you compute the closure of both to see if it contains all the attributes:

``````B+ = B
B+ = BCEF (by using the dependency B → CEF)
B+ = BCEFDG (by using B → DG)
B+ = BCEFDGA (by using G → AD), all the attributes, B is a candidate key
``````

While for G:

``````G+ = G
G+ = GADB (by using GA → B)
G+ = GADBCEF (by using B → CEF), all the attributes, G is a candidate key
``````

No other set of attributes is a candidate key, since the only other attribute on the left side is `A`, but `GA` is determined by `G`, so it can be eliminated from that dependency.

Actually a canonical cover of the original set of dependencies is:

``````{ B → C
B → E
B → F
B → G
G → A
G → D
G → B }
``````