views:

118

answers:

2

I would like to find the canonical cover or minimum number of functional dependencies in a database.

For example:

If you have: Table = (A,B,C) <-- these are columns: A,B,C

And dependencies:

A → BC

B → C

A → B

AB → C

The canonical cover (or minimum number of dependencies) is:

A → B

B → C

Is there a program that can accomplish this? If not, any code/pseudocode to help me write one would be appreciated. Prefer in Python or Java.

A: 

Looking at your dependencies, it looks like you can view them as a partial order on A, B, C. What you want sounds a lot like (but not entirely) a topological sort (a partial order sort on a directed acyclic graph).

rlotun
Can you show me how a topological sort would minimize those dependencies into the canonical cover i've described in my question?
Sev
A: 

Looks to me like you can refactor any rules of the form:

   A ->  BC

into

 A -> B

and

  A -> C

and any rules of the form:

  AB -> C

into

  A -> C

and

  B -> C

After this refactoring, you should have a set of rules of the singleton pairs:

  X -> Y

(Likely with lots of redundant copies you can immediately remove). This forms the partial order that rlotun seemed to referring to.

For the example so far, you end up with:

 A -> B
 B -> C
 A -> C

If you then minimize the partial order (e.g., remove any redundant links, any data structure books on partial should tell you how to do that), you'll have a minimal partial order, and I think that's the answer you want. Minimizing the partial order in the example, you'd delete A -> C from the partial order, ending with your answer.

Ira Baxter
assuming those are the only rules when minimizing dependencies. i'm sure there are other rules...i guess that's the implied question here too. what are the rules used to minimize dependencies?
Sev
for example: what rule would you use for AB -> DE dependency? or ABC -> EDF or A -> BCF
Sev
AB -> DE just means that A -> DE and B -> DE, and break it down further from there.
Ira Baxter
AB -> DE does NOT imply A -> DE! A good source on dependency theory is Maier, "Theory of Relational Databases".
dportas
Ya, I think it implies AB->D and AB->E
Sev