|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fesenmeyer.dbnormalizer.core.algorithms.FDChecker
public class FDChecker
Class which gives the possibility to check if a FD
is satisfied by the current content of a Table (method checkFD(String, FD)
).
This is done by constructing an appropriate SQL query based on the FD and
running this query against the DB.
Field Summary | |
---|---|
private Connection |
conn
The SQL-Connection to be used to access the DB. |
private static String |
DERIVED_TABLE_ALIAS
Constant for the name of the derived table constructed by the SQL Statement. |
private static DBNormalizerLogger |
logger
The logger for this class. |
Constructor Summary | |
---|---|
FDChecker(Connection conn)
Class constructor specifying the SQL-Connection to be used. |
Method Summary | |
---|---|
FDCheckState |
checkFD(String qualifiedTableName,
FD fd)
Checks if the FD specified by argument fd is satisfied in the table specified by argument qualifiedTableName. |
private String |
getCheckFDStatement(String qualifiedTableName,
FD fd)
Creates an SQL Statement, which can be used to check if the FD specified by the fd argument is satisfied by the Table specified by the qualifiedTableName argument. |
private String |
getCheckNoDataStatement(String qualifiedTableName)
Creates an SQL query to check if the table specified by argument qualifiedTableName contains any data. |
DataSet |
getNotSatisfiedTupels(String qualifiedTableName,
FD fd)
Returns the tuples returned by the SQL query used for checking FDs. |
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 Connection conn
private static final String DERIVED_TABLE_ALIAS
Constructor Detail |
---|
public FDChecker(Connection conn)
conn
- a SQL-ConnectionMethod Detail |
---|
public FDCheckState checkFD(String qualifiedTableName, FD fd) throws DBException
Checks if the FD specified by argument fd is satisfied in the table specified by argument qualifiedTableName. As a first step, the method checks if the table contains data. If it does not contain any data, it is not possible to check the FD.
To check if the FD
{lectureno, matrno} -> {name, semester}holds in the table with the qualified name
university.students
,
the following query is run:
SELECT lectureno, matrno, COUNT(*) AS rhscount FROM (SELECT DISTINCT lectureno, matrno, name, semester FROM university.students) distinctrows GROUP BY lectureno, matrno HAVING COUNT(*) > 1If the query does not return any row, the FD is satisfied. Otherwise, it is not satisfied.
qualifiedTableName
- the qualified name of a tablefd
- a FD possibly holding in the table specified by argument qualifiedTableName
FDCheckState.NO_DATA
, if the table does not contain any row of data.FDCheckState.SATISFIED
, if the query described above does not return any row.FDCheckState.NOT_SATISFIED
, if the query described above returns at least one row.DBException
- if an SQL Exception occurs, e.g. because the table or the
attributes of the FD do not exist, or because the DBS does not support the
syntax used in the created SQL querypublic DataSet getNotSatisfiedTupels(String qualifiedTableName, FD fd) throws DBException
DataSet
object.
qualifiedTableName
- a qualified table namefd
- a FD
DBException
- if an SQL Exception occurs, e.g. because the table or the
attributes of the FD do not exist, or because the DBS does not support the
syntax used in the created SQL querycheckFD(String, FD)
private String getCheckNoDataStatement(String qualifiedTableName)
qualifiedTableName
-
private String getCheckFDStatement(String qualifiedTableName, FD fd)
qualifiedTableName
- a qualified table namefd
- a FD
checkFD(String, FD)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |