Functional dependency calculator

$Id: functional-dependencies.php,v 1.11 2006/04/10 16:32:48 bigfoot Exp $

INPUT:

Column names (space separated):

Table data (fields space separated, rows newline separated)
(calculations will suppose this is the FULL set of representative data):

OUTPUT:

->"functionally determines"
Ffull functional dependency
Ppartial functional dependency
Ckey candidate
C!minimal length key candidate
Ttransitive dependency to underlined dependents (experimental!)
1. Project_No->Pers_ID  F  
2. Project_No, Pers_ID, Dept_No->Job, Salary  PCT
3. Project_No, Pers_ID, Dept_No, Job->Salary  PC 
4. Project_No, Pers_ID, Dept_No, Salary->Job  PC 
5. Project_No, Pers_ID, Job->Dept_No, Salary  PC 
6. Project_No, Pers_ID, Job, Salary->Dept_No  PC 
7. Project_No, Pers_ID, Salary->Dept_No, Job  PC 
8. Project_No, Dept_No->Pers_ID, Job, Salary  PC!T
9. Project_No, Dept_No, Job->Pers_ID, Salary  PCT
10. Project_No, Dept_No, Job, Salary->Pers_ID  PC 
11. Project_No, Dept_No, Salary->Pers_ID, Job  PCT
12. Project_No, Job->Pers_ID, Dept_No, Salary  PC!T
13. Project_No, Job, Salary->Pers_ID, Dept_No  PCT
14. Project_No, Salary->Pers_ID, Dept_No, Job  PC!T
15. Pers_ID, Dept_No, Job->Salary  P  
16. Pers_ID, Dept_No, Salary->Job  P  
17. Pers_ID, Job->Salary  P  
18. Pers_ID, Salary->Job  P  
19. Dept_No->Pers_ID  F  
20. Dept_No, Job->Pers_ID, Salary  P T
21. Dept_No, Job, Salary->Pers_ID  P  
22. Dept_No, Salary->Pers_ID, Job  P T
23. Job->Pers_ID, Salary  F T
24. Job, Salary->Pers_ID  P  
25. Salary->Pers_ID, Job  F T


EXAMPLES

partially taken from Maciej Suchomski's exercise slides
(NEW: click "try it" to run the example):


(1)
A B C D E
---------
a b z w q
e b r w p
a d z w t
e d r w q
a f z s t
e f r s t
try it
(2) (default)
A B C
-----
a b x
a b y
a d x
a d y
c f x
c f y
try it
(3)
A B C D E
---------
a b x v q
e b y v z
a d x v t
e d y v p
a f x p t
e f y p z
try it
Cust# Name  Address
-------------------
43    Jones 121_1st
55    Smith 222_2nd
try it
Invoice# Line# Quant1 Part1      Amt1
-------------------------------------
1001     1     200    Screw      2.00
1001     2     300    Nut        2.25
1001     3     100    Whatever   0.75
1002     1       1    Motor     52.00
1002     2      10    Saw      121.00
1003     3       5    Brace     44.44
try it
Project_No Pers_ID Dept_No Job Salary
-------------------------------------
5 1 1 Analysis  13
5 1 2 Leader    18
7 1 1 Leader    18
8 1 1 Marketing 15
8 1 2 Leader    18
try it
transitive dependency?
A B C
-----
a a 1
b a 1
c b 1
d b 1
e c 2
f c 2
try it