|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fesenmeyer.dbnormalizer.core.algorithms.NFDetermination
public class NFDetermination
This class implements an algorithm for the determination of the normal form of a table (from 1NF to BCNF). The algorithms are based on the definitions in [Fundamentals of database systems, 5th Ed., Elmasri/Navathe, 2007].
Field Summary | |
---|---|
private Set<AttributeStringSet> |
candidateKeys
The candidate keys of the table. |
private Set<FD> |
fds
The FDs of the table. |
private static DBNormalizerLogger |
logger
The logger for this class. |
private boolean |
onlySimpleKeys
flag, which is true , if the table only contains
"simple" keys (keys consisting of one attribute) |
private Table |
table
The table for which the normal form should be determined. |
private Map<NormalForm,Set<FD>> |
violatingFDs
Map, which holds for each key (normal form) the FDs which violate this normal form |
Constructor Summary | |
---|---|
NFDetermination(Table table)
Class Constructor specifying the table for which the normal form should be determined. |
Method Summary | |
---|---|
private void |
addToViolatingFDs(NormalForm nf,
FD fd)
Helper method which adds a FD to the map of violating FDs. |
NFDeterminationResult |
determine()
The normal form determination algorithm, which returns the normal form and the FDs violating one of the normal forms 2NF, 3NF or BCNF. |
private void |
initialize(Table table)
Helper method for initialization of the member variables of this class. |
private boolean |
isKeyAttribute(String attr)
Helper method which looks if the attribute specified by argument attr is part of a candidate key (a prime attribute). |
private boolean |
violates2NF(FD fd)
Checks if a FD violates 2NF. |
private boolean |
violates3NF(FD fd)
Checks if a FD violates 3NF. |
private boolean |
violatesBCNF(FD fd)
Checks if a FD violates BCNF. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static DBNormalizerLogger logger
private Set<AttributeStringSet> candidateKeys
private Table table
private Set<FD> fds
private boolean onlySimpleKeys
true
, if the table only contains
"simple" keys (keys consisting of one attribute)
private Map<NormalForm,Set<FD>> violatingFDs
Constructor Detail |
---|
public NFDetermination(Table table)
table
- a Table objectMethod Detail |
---|
private void initialize(Table table) throws DBNormalizerException
table
- the table
DBNormalizerException
public NFDeterminationResult determine() throws DBNormalizerException
The normal form determination algorithm, which returns the normal form and the FDs violating one of the normal forms 2NF, 3NF or BCNF.
NOTE: Before applying this method to a table, make sure that it contains
all the necessary data such as minimal cover (Table.setFDMinCover(java.util.Set)
)
and candidate keys (Table.setCandKeys(java.util.Set)
). The methods for calculating
this data can be found in the FDAlgorithms
class.
DBNormalizerException
NFDeterminationResult
private boolean violates2NF(FD fd)
fd
- the FD to be checked
true
, if the FD violates 2NF;
false
, otherwiseprivate boolean violates3NF(FD fd)
fd
- the FD to be checked
true
, if the FD violates 3NF;
false
, otherwiseprivate boolean violatesBCNF(FD fd)
fd
- the FD to be checked
true
, if the FD violates BCNF;
false
, otherwiseprivate boolean isKeyAttribute(String attr)
attr
- an attribute name
true
, if the attribute is part of a candidate key;
false
, otherwiseprivate void addToViolatingFDs(NormalForm nf, FD fd)
nf
- the normal form which is violated by the FDfd
- the FD
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |