Determine Keys from Functional Dependencies
Since you're in a db theory course, I'm going to assume you have SQL experience and try and relate the theory to the implementation context.
Basically, a relation is what you would refer to as a table in implementation and a key is ANY set of attributes (read columns) which can be used to identify a UNIQUE row (in db theory this would be a tuple). The simplest analogy here is that a key is your primary key, as well as any other possible set of columns you can use to identify a single tuple in your relation (row in your table). So, here are the basic steps for doing this (I'll walk through example A, and then you can try the rest):
- List all of the attributes which are NOT in your proposed key (so BCDEF does not include A and G).
For each attribute you're missing, go through the list of functional dependencies and see if your proposed key is capable of inferring the attribute you're missing.
a. So for A, you have BC -> A. Since both B and C are in the proposed key BCDEF, you can infer that BCDEF -> A. Your set now becomes BCDEFA. b. For G, again going through your FDs you find EF -> G. Since both E and F are in BCDEFA, you can infer BCDEFA -> G.
Because you were able to infer both A and G from BCDEF, option a is a key of the relation ABCDEFG. I know there is an algorithm for this, and it is probably in your course text somewhere. There is also probably an example. You should step through it manually until the pattern is intuitive.
EDIT: The reason I would go back through the text to look for this algorithm is that chances are your exam is going to be written as opposed to multiple choice since it is a db theory course. If this is true then you would get more partial credit if you can methodically follow notation demonstrated in your course text/notes.
The main goal is to turn the key into the relation, which should prove that the proposed key is in fact a key.
Well this should be rather straightforward. All you need to do is to take the closure of every key given and see if it contains all attributes of R. For example, closure of BCDEF = ABCDEFG since BC -> A and BC is a subset of BCDEF and so if EF for FD EF -> G. Since this closure contains all attributes of R, BCDEF is the key. The main aim of taking closures is to see if we can "reach" every attribute from a given set of attributes. The closure is the set of attributes that we can actually reach by navigating the FDs.
Take an FD, e.g. AB→C
Augment until all attributes are mentioned, e.g. ABDEFG → CDEFG (note that this is equivalent to ABDEFG → ABCDEFG because it is trivially true that A->A and B->B).
This tells you that ABDEFG is a superkey.
Check the other FDs in which the LHS is a subset of your superkey, and that on its RHS contains some other attribute of your superkey.
There are two. EF→G and FG→E. Remove the attributes of the RHS of these from your superkey. Doing so gives you two keys, that are certainly superkeys, but not necessarily irreducible ones: ABDEF and ABDFG.
However, from AB→C and CD→E we can also derive that ABD→E. Hence we can also remove the E from our ABDEF key. The nasty thing here is that when I said "Check the other FDs", that apparently means that you should also check any FD that appears in the closure of your set of FDs (i.e. any FD that is derivable from your given set of FDs)... And that's a bit impractical to do by hand ...
A useful site for verifying whether your results are correct:
http://raymondcho.net/RelationalDatabaseTools/RelationalDatabaseTools
You should now be able to determine that option c is a key.
well, i'm no expert for this stuff, so correct me if i'm wrong, but my approach would be to eliminate impossible answers
in this case:
none of your FDs "gives" you B, D or F ... since those are part of the relation there can be no super key that does not contain B, D and F ... remove answer b (B is missing) ... remove answer d (F is missing)
now let's check the remaining answers if they contain enough information to get all parts of the relation
answer a (BCDEF) will "give" you B, C, D, E and F so you need to find A and G using the FDs ... A can be reached by BC and G can be reached by EF, so answer a is a key
answer c (BDFG) will "give" you B, D, F and G so you need to find A, C and E using the FDs ... E can be reached by FG ... C can be reached by DE (after reaching E by FG) ... and finally A can be reached by BC (after reaching C) ...
so answer c is some sort of key since the whole relation can be accessed this way ... but i don't know if this is enough to fit the formal definition ... if i'd have to guess, i'd say no