I'm having trouble understanding how to identify keys in functional dependencies. I've been looking at examples, for example:
Given a relation ABCD, find all keys not including superkeys of the
A -> BC, C -> D, CD -> AB.
This gives keys C and A. The way I thought this problem was approached was that BC and D both depend on A and C, and AB depends on CD, meaning all three of them are keys, but since CD is a superkey (C is a subset that is also a key), CD is not considered a minimal superkey.
However, in another example,
ABCDE
AB → CD
E → A
D → A
The only key here is apparently BE. Why is this true, and can anyone clarify the steps to take in finding keys with these problems?
Thanks.
The second one's a bit simpler, so taking it first . . . you know that B must be in any key, because it's not on any right-hand side. (That is, even if you have the values of ACDE, you couldn't infer the value of B.) Similarly for E; so, any key must include BE. But BE is by itself a sufficient key, because E gives you A (hence BE → ABE) and AB gives you CD (hence BE → ABCDE).
In the first one, we can see that A is a key, because A gives you B and C, and C gives you D. Similarly, C is a key, because C gives you D, and C and D together give you A and B. Conversely, we see that A and/or C must be in any key, because every left-hand-side includes at least one of them.