public abstract class RelationCheck extends java.lang.Object implements RelationInformation
Constructor and Description |
---|
RelationCheck() |
Modifier and Type | Method and Description |
---|---|
boolean |
areFdSetsEquivalent(java.util.ArrayList<FunctionalDependency> list1,
java.util.ArrayList<FunctionalDependency> list2)
Returns if two Sets of Functional Dependencies are equivalent
|
void |
copyAttributes(java.util.ArrayList<Attribute> sourceList,
java.util.ArrayList<Attribute> targetList)
Copies a set of Attributes to another set of Attributes
|
java.util.ArrayList<Key> |
getAllCandidateKeys(RelationSchema schema)
Returns all candidate - keys
|
AttributePosition |
getAttributePosition(Attribute attribute,
java.util.ArrayList<FunctionalDependency> fds)
Returns the Position of the Attribute in the given fd's
|
java.util.ArrayList<Attribute> |
getClosure(java.util.ArrayList<FunctionalDependency> fds,
java.util.ArrayList<Attribute> determiningAttributes)
Returns the Closure of given Attributes
|
java.util.ArrayList<Attribute> |
getClosure(RelationSchema schema,
java.util.ArrayList<Attribute> determiningAttributes)
Returns the Closure of given Attributes
|
java.util.ArrayList<FunctionalDependency> |
getMinimalSetOfFds(java.util.ArrayList<FunctionalDependency> fds)
Returns a ArrayList containing the minimal set of functional
dependencies
|
abstract NormalForm |
getNF(RelationSchema schema,
java.util.ArrayList<FunctionalDependency> violatingFds) |
int |
getNumberOfMatchingAttributes(java.util.ArrayList<Attribute> list1,
java.util.ArrayList<Attribute> list2)
Returns the number of matching items of two lists
|
java.util.ArrayList<Attribute> |
getOnlyDeterminedAttributes(RelationSchema schema) |
Key |
getPrimaryKey(RelationSchema schema)
Returns a Key-Object, that contains all Attributes marked as
Primary Key
|
java.util.ArrayList<java.util.ArrayList<Attribute>> |
getSubsetOfAttributes(java.util.ArrayList<Attribute> attributes,
java.util.ArrayList<java.util.ArrayList<Attribute>> resultList)
Returns all subsets of a given ArrayList
|
abstract boolean |
isBCNF(RelationSchema schema) |
boolean |
isCandidateKey(java.util.ArrayList<Attribute> keyToTest,
java.util.ArrayList<Key> candidateKeys)
Tells if a number of Attributes are a candidateKey
|
boolean |
isKeyDeterminingEverything(java.util.ArrayList<Attribute> attributes,
java.util.ArrayList<FunctionalDependency> fds,
Key key)
Returns if a Key determines all Attributes of a given relation
|
boolean |
isKeyDeterminingEverything(RelationSchema schema,
Key key)
Returns if a Key determines all Attributes of a given relation
|
boolean |
isMember(RelationSchema schema,
FunctionalDependency fd)
Checks if a given functional dependency is a Member of a schema
|
boolean |
isPrimeAttribute(Attribute attribute,
java.util.ArrayList<Key> candidateKeys)
Returns if a given Attribute is a prime Attribute
|
abstract boolean |
isSecondNF(RelationSchema schema) |
boolean |
isSetOfFDsCannonical(java.util.ArrayList<FunctionalDependency> setOfFDs)
Returns true/false if Set of FD's is cannonical
|
boolean |
isSuperKey(java.util.ArrayList<Attribute> keyToTest,
java.util.ArrayList<Key> candidateKeys)
Tells if a number of Attributes are a superKey
|
abstract boolean |
isThirdNF(RelationSchema schema) |
java.util.ArrayList<FunctionalDependency> |
makeFdCannonical(FunctionalDependency fd)
Returns the cannonical parts of a FD, or the FD if it was already
cannonical
|
void |
removeRedundantFunctionalDependencies(java.util.ArrayList<FunctionalDependency> fds)
Removes redundant functional dependencies from the ArrayList
|
java.util.ArrayList<FunctionalDependency> |
removeUnneccessarySourceAttributes(java.util.ArrayList<FunctionalDependency> fdList)
Returns a ArrayList of FunctionalDependencies, no unnecessary
Attributes on the Left side
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
checkForBCNF, checkForSecondNF, checkForThirdNF, getNF
public abstract boolean isSecondNF(RelationSchema schema)
isSecondNF
in interface RelationInformation
public abstract boolean isThirdNF(RelationSchema schema)
isThirdNF
in interface RelationInformation
public abstract boolean isBCNF(RelationSchema schema)
isBCNF
in interface RelationInformation
public abstract NormalForm getNF(RelationSchema schema, java.util.ArrayList<FunctionalDependency> violatingFds)
getNF
in interface RelationInformation
public int getNumberOfMatchingAttributes(java.util.ArrayList<Attribute> list1, java.util.ArrayList<Attribute> list2)
list1
- the first listlist2
- the second listpublic boolean isPrimeAttribute(Attribute attribute, java.util.ArrayList<Key> candidateKeys)
attribute
- the attribute to be checkedcandidateKeys
- the candidate Keys in which to look for the attributepublic java.util.ArrayList<FunctionalDependency> getMinimalSetOfFds(java.util.ArrayList<FunctionalDependency> fds)
getMinimalSetOfFds
in interface RelationInformation
fds
- functional dependencies to checkpublic boolean isSetOfFDsCannonical(java.util.ArrayList<FunctionalDependency> setOfFDs)
setOfFDs
- to checkpublic java.util.ArrayList<FunctionalDependency> makeFdCannonical(FunctionalDependency fd)
fd
- the FunctionalDependency to operate onpublic java.util.ArrayList<FunctionalDependency> removeUnneccessarySourceAttributes(java.util.ArrayList<FunctionalDependency> fdList)
fdList
- ArrayList of FunctionalDependencies to work withpublic void removeRedundantFunctionalDependencies(java.util.ArrayList<FunctionalDependency> fds)
fds
- ArrayList to clean uppublic java.util.ArrayList<java.util.ArrayList<Attribute>> getSubsetOfAttributes(java.util.ArrayList<Attribute> attributes, java.util.ArrayList<java.util.ArrayList<Attribute>> resultList)
attributes
- the initial ArrayList of AttributesresultList
- a empty ArrayList of ArrayListspublic Key getPrimaryKey(RelationSchema schema)
getPrimaryKey
in interface RelationInformation
schema
- schema which contains the Attributespublic java.util.ArrayList<Key> getAllCandidateKeys(RelationSchema schema)
getAllCandidateKeys
in interface RelationInformation
schema
- schema to work withpublic java.util.ArrayList<Attribute> getOnlyDeterminedAttributes(RelationSchema schema)
public AttributePosition getAttributePosition(Attribute attribute, java.util.ArrayList<FunctionalDependency> fds)
attribute
- attribute to be searchedfds
- fds in which to look for the attributepublic boolean isSuperKey(java.util.ArrayList<Attribute> keyToTest, java.util.ArrayList<Key> candidateKeys)
keyToTest
- the key to testcandidateKeys
- the candidateKeys to test againstpublic boolean isCandidateKey(java.util.ArrayList<Attribute> keyToTest, java.util.ArrayList<Key> candidateKeys)
isCandidateKey
in interface RelationInformation
keyToTest
- the key to testcandidateKeys
- the candidateKeys to test againstpublic boolean isKeyDeterminingEverything(RelationSchema schema, Key key)
isKeyDeterminingEverything
in interface RelationInformation
schema
- schema which contains the attributeskey
- key under testpublic boolean isKeyDeterminingEverything(java.util.ArrayList<Attribute> attributes, java.util.ArrayList<FunctionalDependency> fds, Key key)
attributes
- attributes that must be determinedfds
- functional dependencies to considerkey
- key to be testedpublic boolean isMember(RelationSchema schema, FunctionalDependency fd)
schema
- schema to work withfd
- functional dependency to testpublic java.util.ArrayList<Attribute> getClosure(RelationSchema schema, java.util.ArrayList<Attribute> determiningAttributes)
schema
- schema to work withdeterminingAttributes
- Closure(determiningAttributes)public java.util.ArrayList<Attribute> getClosure(java.util.ArrayList<FunctionalDependency> fds, java.util.ArrayList<Attribute> determiningAttributes)
fds
- functional dependencies to considerdeterminingAttributes
- determining attributes to work withpublic boolean areFdSetsEquivalent(java.util.ArrayList<FunctionalDependency> list1, java.util.ArrayList<FunctionalDependency> list2)
areFdSetsEquivalent
in interface RelationInformation
list1
- first set of fd's to considerlist2
- second set of fd's to consider