public class RelationUtils
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
void |
determineAllAttributes(RelationSchema relation)
Let all undetermined Attributes be determined by the primaryKey
|
java.util.ArrayList<Attribute> |
getDeterminedAttributes(RelationSchema relation)
Returns a ArrayList of Attributes which are determined by at
least one fd
|
static RelationUtils |
getInstance() |
Key |
getKey(java.util.ArrayList<Key> keyList)
Returns the smallest of all candidateKeys
|
Key |
getKey(RelationSchema schema)
Returns the CandidateKey with fewest Attributes s
|
java.lang.String |
getNormalFormText(NormalForm nf)
Returns the text for a given Normalform
|
Key |
getPrimaryKey(RelationSchema schema)
Returns a Key made of all Attributes marked as PK
|
java.lang.String |
getRelationName(java.lang.String name,
java.util.ArrayList<RelationSchema> schema)
Returns a name for a new Relation
|
boolean |
isFdContainingGivenAttributes(FunctionalDependency fd,
java.util.ArrayList<Attribute> attributes)
Checks if at least one side of the given Fd contains a given
Attribute
|
boolean |
relationNameAlreadyExists(java.lang.String name,
java.util.ArrayList<RelationSchema> schema)
Returns if a given Relation-name already exists
|
void |
resetPrimaryKey(RelationSchema schema)
Resets the Primary Key to the optimal choice
|
void |
restoreAttributesByFds(RelationSchema schema)
Restores Attributes of the given relation with the attributes of
the functionalDependencies
|
void |
uniteFdsWithSameLeftSide(java.util.ArrayList<FunctionalDependency> fdList)
Unites all fd's with equal left sides
|
public static RelationUtils getInstance()
public java.lang.String getRelationName(java.lang.String name, java.util.ArrayList<RelationSchema> schema)
name
- name of the parent-relationschema
- the RelationSchema to work withpublic boolean relationNameAlreadyExists(java.lang.String name, java.util.ArrayList<RelationSchema> schema)
name
- the name to look forschema
- the RelationSchema to work withpublic Key getKey(RelationSchema schema)
schema
- the RelationSchema to get the Keys frompublic Key getKey(java.util.ArrayList<Key> keyList)
keyList
- a list with all candidateKeyspublic Key getPrimaryKey(RelationSchema schema)
schema
- the relation to work withpublic void restoreAttributesByFds(RelationSchema schema)
schema
- the relation to work withpublic boolean isFdContainingGivenAttributes(FunctionalDependency fd, java.util.ArrayList<Attribute> attributes)
fd
- Functional Dependency to work withattributes
- Attributes to look forpublic void uniteFdsWithSameLeftSide(java.util.ArrayList<FunctionalDependency> fdList)
fdList
- to work withpublic void resetPrimaryKey(RelationSchema schema)
public java.lang.String getNormalFormText(NormalForm nf)
nf
- the nf to get a text forpublic void determineAllAttributes(RelationSchema relation)
relation
- the relation to work withpublic java.util.ArrayList<Attribute> getDeterminedAttributes(RelationSchema relation)
relation
- the relation to work with