Plouj
public text v1 · immutable class FunctionalDependency {
LinkedList<String> LeftHandSide;
LinkedList<String> RightHandSide;
...
class Relation {
LinkedList<FunctionalDependency> FDs;
...
public Relation elimRedundantAttributes() {
Relation R = new Relation(FDs);
for (FunctionalDependency fd: R.getFDs()) {
if (fd.getLHS().size() > 1) {
for (Iterator<String> AttrList = fd.getLHS().iterator();
AttrList.hasNext(); ) {
String A = AttrList.next();
// can we eliminate this attribute from the LHS?
FunctionalDependency smallerFD = fd.removeLHS(A);
Relation altRel = R.removeFD(fd);
altRel = altRel.addFD(smallerFD);
if (altRel.closureOfAttributeSet(smallerFD.getLHS()).containsAll(fd.getLHS())
// apparently yes
System.out.println(A+" is redundant in "+fd);
// remove it from the original LHS somehow...
}
}
}
}
return R;
}