What would be the Candidate key (s) of this relation

normalizationrelational-theory

R(ABCDEPG)

F={AB->CD, DE->P, C->E, P->C, B->G}

To my consideration, the candidate keys are: AB, AG, CD, DE.

Am I correct? Why or why not?

Best Answer

Unless I have mistaken the question, your response of candidate keys is incorrect.

Candidate Key AB: AB -> CD, C->E, DE->P, B -> G. This is a candidate key.

Candidate Key AG: A, G, and AG have no inherent relations. Just because B->G doesn't mean that G->B (a similar mistake was made after assuming B was solved and getting the columns of A and B). This is not a candidate key.

Candidate Key CD/DE: This is not a candidate key. There is no possible way for F to have a candidate key that does not include A, as there is no way to determine A without it being part of the key. Similarly, nothing implies B and thus it is required to be part of any candidate key.

Since AB is a candidate key, there is no reason to go further. Any candidate key must include AB and AB is a candidate key, therefore the only candidate key is AB. A and B must both be supplied as part of the key or else there can be no unique identifiers to their values. Since keys are typically generated with the intent to use the least information possible to determine uniqueness, AB being required for row uniqueness, and AB being a potential key then you can select it as your primary composite key and move on.