How to determine BCNF

djd97 picture djd97 · Oct 8, 2016 · Viewed 10.8k times · Source

I've already read a bunch of other threads involving BCNF on SO, but I'm still a bit confused about how I would write a function to determine if a relation was in BCNF given the relation and a list of its functional dependencies.

So obviously if the union of all inputs and outputs of the FD's don't equal the relation, then it's not in BCNF, but that's also obviously all I need to check.

So, say I'm given an input: 
R(A,B,C,D,E,F,G)
A->B
C,D->F
G->E

Then what would I need to check to determine if it's BCNF?

Answer

Renzo picture Renzo · Oct 8, 2016

A relation is in BCNF if and only if each functional dependency X → Y has a determinant (X) which is a superkey, that is, it determines all the other attributes of the relation.

To observe this, you can calculate the “closure” of the determinant with respect to the set of functional dependencies: if it contains all the attributes, than it is a superkey.

So, for instance, in your example we have that the closure of A is A itself plus B:

A+ = AB

This means that A is not a superkey, and the relation is not in BCNF. In fact, the only key of your relation is A C D G.