de.fesenmeyer.dbnormalizer.core
Class FK

java.lang.Object
  extended by de.fesenmeyer.dbnormalizer.core.AbstractDBItem
      extended by de.fesenmeyer.dbnormalizer.core.FK
All Implemented Interfaces:
Comparable<FK>

public class FK
extends AbstractDBItem
implements Comparable<FK>

This class represents a Foreign Key relationship (FK) between two tables. The referenced table is called the PK-Table, because it contains the primary key which is referenced. The properties of this class with the prefix pk hence describe the referenced table. The referencing table is also called the FK-Table, because it defines the FK. The properties of this class with the prefix fk hence describe the referencing table.

Author:
DF

Field Summary
private  int deferability
          The deferability.
private  int deleteRule
          The delete rule.
private  String fkCatalog
          The catalog of the FK-Table, may be null.
private  List<String> fkColumnNames
          The referencing columns of the FK-Table.
private  String fkSchema
          The schema of the FK-Table, may be null.
private  String fkTableName
          The name of the FK-Table.
private  String pkCatalog
          The catalog of the PK-Table, may be null.
private  List<String> pkColumnNames
          The referenced columns of the PK-Table.
private  String pkName
          The name of the referenced PK.
private  String pkSchema
          The schema of the PK-Table, may be null.
private  String pkTableName
          The name of the PK-Table.
private  int updateRule
          The update rule.
 
Constructor Summary
FK()
           
 
Method Summary
 int compareTo(FK fk)
          Default implementation for comparing FKs.
 boolean equals(Object obj)
          Overridden method, which compares this FK to an arbitrary object.
 int getDeferability()
          Gets the deferability.
 int getDeleteRule()
          Gets the deleteRule.
 String getFkCatalog()
          Gets the catalog of the FK-Table, may be null.
 List<String> getFkColumnNames()
          Gets the referencing columns of the FK-Table.
 String getFkSchema()
          Gets the schema of the FK-Table, may be null.
 String getFkTableName()
          Gets the name of the FK-Table.
 String getPkCatalog()
          Gets the catalog of the PK-Table, may be null.
 List<String> getPkColumnNames()
          Gets the referenced columns of the PK-Table.
 String getPkName()
          Gets the name of the referenced PK.
 String getPkSchema()
          Gets the schema of the PK-Table, may be null.
 String getPkTableName()
          Gets the name of the PK-Table.
 int getUpdateRule()
          Gets the updateRule.
 int hashCode()
          Overridden method which compares a hashcode based on the toString() method.
 void setDeferability(int deferability)
          Sets the deferability.
 void setDeleteRule(int deleteRule)
          Sets the deleteRule.
 void setFkCatalog(String fkCatalog)
          Sets the schema of the FK-Table, may be null.
 void setFkColumnNames(List<String> fkColumnNames)
          Sets the referencing columns of the FK-Table.
 void setFkSchema(String fkSchema)
          Sets the schema of the FK-Table, may be null.
 void setFkTableName(String fkTableName)
          Sets the name of the FK-Table.
 void setPkCatalog(String pkCatalog)
          Sets the catalog of the PK-Table, may be null.
 void setPkColumnNames(List<String> pkColumnNames)
          Sets the referenced columns of the PK-Table.
 void setPkName(String pkName)
          Sets the name of the referenced PK.
 void setPkSchema(String pkSchema)
          Sets the schema of the PK-Table, may be null.
 void setPkTableName(String pkTableName)
          Sets the name of the PK-Table.
 void setUpdateRule(int updateRule)
          Sets the updateRule.
 String toString()
          Overridden method which returns an appropriate string representation of this FK, for example: FK: Table1(A,B) --> Table2(A,B)
 
Methods inherited from class de.fesenmeyer.dbnormalizer.core.AbstractDBItem
getName, setName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

pkCatalog

private String pkCatalog
The catalog of the PK-Table, may be null.


pkSchema

private String pkSchema
The schema of the PK-Table, may be null.


pkTableName

private String pkTableName
The name of the PK-Table.


fkTableName

private String fkTableName
The name of the FK-Table.


fkSchema

private String fkSchema
The schema of the FK-Table, may be null.


fkCatalog

private String fkCatalog
The catalog of the FK-Table, may be null.


updateRule

private int updateRule
The update rule.


deleteRule

private int deleteRule
The delete rule.


pkName

private String pkName
The name of the referenced PK.


deferability

private int deferability
The deferability.


pkColumnNames

private List<String> pkColumnNames
The referenced columns of the PK-Table.


fkColumnNames

private List<String> fkColumnNames
The referencing columns of the FK-Table.

Constructor Detail

FK

public FK()
Method Detail

getPkCatalog

public String getPkCatalog()
Gets the catalog of the PK-Table, may be null.

Returns:
the pkCatalog

setPkCatalog

public void setPkCatalog(String pkCatalog)
Sets the catalog of the PK-Table, may be null.

Parameters:
pkCatalog - the pkCatalog to set

getPkSchema

public String getPkSchema()
Gets the schema of the PK-Table, may be null.

Returns:
the pkSchema

setPkSchema

public void setPkSchema(String pkSchema)
Sets the schema of the PK-Table, may be null.

Parameters:
pkSchema - the pkSchema to set

getPkTableName

public String getPkTableName()
Gets the name of the PK-Table.

Returns:
the pkTableName

setPkTableName

public void setPkTableName(String pkTableName)
Sets the name of the PK-Table.

Parameters:
pkTableName - the pkTableName to set

getFkTableName

public String getFkTableName()
Gets the name of the FK-Table.

Returns:
the fkTableName

setFkTableName

public void setFkTableName(String fkTableName)
Sets the name of the FK-Table.

Parameters:
fkTableName - the fkTableName to set

getFkSchema

public String getFkSchema()
Gets the schema of the FK-Table, may be null.

Returns:
the fkSchema

setFkSchema

public void setFkSchema(String fkSchema)
Sets the schema of the FK-Table, may be null.

Parameters:
fkSchema - the fkSchema to set

getFkCatalog

public String getFkCatalog()
Gets the catalog of the FK-Table, may be null.

Returns:
the fkCatalog

setFkCatalog

public void setFkCatalog(String fkCatalog)
Sets the schema of the FK-Table, may be null.

Parameters:
fkCatalog - the fkCatalog to set

getUpdateRule

public int getUpdateRule()
Gets the updateRule.

Returns:
the updateRule

setUpdateRule

public void setUpdateRule(int updateRule)
Sets the updateRule.

Parameters:
updateRule - the updateRule to set

getDeleteRule

public int getDeleteRule()
Gets the deleteRule.

Returns:
the deleteRule

setDeleteRule

public void setDeleteRule(int deleteRule)
Sets the deleteRule.

Parameters:
deleteRule - the deleteRule to set

getPkName

public String getPkName()
Gets the name of the referenced PK.

Returns:
the pkName

setPkName

public void setPkName(String pkName)
Sets the name of the referenced PK.

Parameters:
pkName - the pkName to set

getDeferability

public int getDeferability()
Gets the deferability.

Returns:
the deferability

setDeferability

public void setDeferability(int deferability)
Sets the deferability.

Parameters:
deferability - the deferability to set

getPkColumnNames

public List<String> getPkColumnNames()
Gets the referenced columns of the PK-Table.

Returns:
the pkColumnNames

setPkColumnNames

public void setPkColumnNames(List<String> pkColumnNames)
Sets the referenced columns of the PK-Table.

Parameters:
pkColumnNames - the pkColumnNames to set

getFkColumnNames

public List<String> getFkColumnNames()
Gets the referencing columns of the FK-Table.

Returns:
the fkColumnNames

setFkColumnNames

public void setFkColumnNames(List<String> fkColumnNames)
Sets the referencing columns of the FK-Table.

Parameters:
fkColumnNames - the fkColumnNames to set

equals

public boolean equals(Object obj)
Overridden method, which compares this FK to an arbitrary object.

Overrides:
equals in class Object
Parameters:
obj - the object to which this FK should be compared
Returns:
true, if the obj argument is not null, another FK and the toString() method returns the same value for both FKs; false, otherwise.

hashCode

public int hashCode()
Overridden method which compares a hashcode based on the toString() method.

Overrides:
hashCode in class Object
Returns:
the computed hashCode

toString

public String toString()
Overridden method which returns an appropriate string representation of this FK, for example:
 FK: Table1(A,B) --> Table2(A,B)
 

Overrides:
toString in class AbstractDBItem
Returns:
the string representation of this FK

compareTo

public int compareTo(FK fk)
Default implementation for comparing FKs. Uses the toString() method to compare the FKs.

Specified by:
compareTo in interface Comparable<FK>
Parameters:
fk - the FK to be compared with this FK.
Returns:
Returns
  • an int value smaller than 0, if the string representation of this FK is smaller than the other FK's one.
  • 0, if the FKs' string representations are equal.
  • an int value greater than 0, if the string representation of this FK is greater than the other FK's one.