DBVIEW
org.dbview.db.structure.Database Class Reference
Collaboration diagram for org.dbview.db.structure.Database:

List of all members.

Public Member Functions

 Database (String in_name)
String getName ()
Table getTable (String in_name)
ArrayList< TablegetTables ()
void generateRelations () throws Exception
ArrayList< TablegetReferenceTables (Table in_dependent_table) throws Exception
ArrayList< TablegetReferenceTables (String in_dependent_table_name) throws Exception
ArrayList< TablegetDependentTables (Table in_reference_table) throws Exception
ArrayList< TablegetDependentTables (String in_reference_table_name) throws Exception
ArrayList< FieldToFieldJoingetRelationsFromReferenceToTarget (Table in_dependent_table, Table in_reference_table) throws Exception
int getTableToTableRelationType (Table in_dependent_table, Table in_reference_table) throws Exception
ArrayList< FieldToFieldJoingetRelationsFromReferenceToTarget (String in_dependent_table_name, String in_reference_table_name) throws Exception
ArrayList< TablegetNeighborhood (Table in_table) throws Exception
ArrayList< TablegetNeighborhood (String in_table_name) throws Exception
ArrayList< TablezoomAroundByTables (ArrayList< Table > in_tables, Integer in_level) throws Exception
ArrayList< TablezoomAroundByNames (ArrayList< String > in_table_names, Integer in_level) throws Exception
UndirectedGraph< Table,
JgraphtTableToTableEdge
jgrapht (ArrayList< Table > in_tables) throws Exception
String toString ()
String getNonTableTag () throws Exception

Static Public Attributes

static final int MIN_0 = 0
static final int MIN_1 = 1
static final int MAX_1 = 1
static final int MAX_N = -1
static final int UNDEFINED_LINK = -1
static final int SOFT_LINK = 0
static final int SOFT_AND_HARD_LINK = 1
static final int HARD_LINK = 2

Package Functions

void addTable (Table in_table) throws org.dbview.db.structure.DatabaseException

Private Member Functions

Hashtable< Table,
TableToTableRelation
__getRelationsFromTable (Table in_dependent_table) throws Exception
void __updateMetaRelationType (TableToTableRelation in_meta, int new_relation_type)
Hashtable< Table, ArrayList
< FieldToFieldJoin > > 
__getRelationsToTable (Table in_reference_table) throws Exception

Private Attributes

Hashtable< String, Table__tables = new Hashtable<String, Table>()
Hashtable< Table, Hashtable
< Table, TableToTableRelation > > 
__relations = null
String __name = null

Static Private Attributes

static Integer __n = 0

Detailed Description

This class represents a database.

Author:
Denis Beurive

Definition at line 42 of file Database.java.


Constructor & Destructor Documentation

org.dbview.db.structure.Database.Database ( String  in_name)

Create a database.

Parameters:
in_nameName of the database.

Definition at line 132 of file Database.java.


Member Function Documentation

Hashtable<Table, TableToTableRelation> org.dbview.db.structure.Database.__getRelationsFromTable ( Table  in_dependent_table) throws Exception [private]

This method returns the relations from a given "dependent" table (to a list of "reference" table(s)).

Parameters:
in_dependent_tableTable for which you want to get the list of relations.
Returns:
The method returns a hash table that contains "table to table" relation(s).
  • Keys: A "reference" table.
  • Values: The "table to table" relation between the given "dependent" table and its associated "reference" tables.
Exceptions:
Exception

Definition at line 452 of file Database.java.

Referenced by org.dbview.db.structure.Database.generateRelations().

Hashtable<Table, ArrayList<FieldToFieldJoin> > org.dbview.db.structure.Database.__getRelationsToTable ( Table  in_reference_table) throws Exception [private]

This method returns the list of joins (between fields) to a given "reference" table.

Parameters:
in_reference_tableTable for which you want to get the list of joins to.
Returns:
The method returns a hash table that contains the list of joins to the given (reference) table.
  • Keys : "Dependent" tables.
  • Values : A list of joins.

Definition at line 503 of file Database.java.

Referenced by org.dbview.db.structure.Database.getDependentTables().

void org.dbview.db.structure.Database.__updateMetaRelationType ( TableToTableRelation  in_meta,
int  new_relation_type 
) [private]

This method is used by the method "__getRelationsFromTable()" only.

Parameters:
in_meta"Table to table" relation to update.
new_relation_typeType of the new "field to field" relation found in the "table to table" relation.

Definition at line 486 of file Database.java.

Referenced by org.dbview.db.structure.Database.__getRelationsFromTable().

void org.dbview.db.structure.Database.addTable ( Table  in_table) throws org.dbview.db.structure.DatabaseException [package]

Add a table to the database.

Parameters:
in_tableTable to add.
Exceptions:
org.dbview.db.structure.DatabaseException
Remarks:
This method is accessible for package's members only. Adding a table to a database is done when a table is created.

Definition at line 175 of file Database.java.

Referenced by org.dbview.db.structure.Table.Table().

void org.dbview.db.structure.Database.generateRelations ( ) throws Exception
ArrayList<Table> org.dbview.db.structure.Database.getDependentTables ( Table  in_reference_table) throws Exception

This method returns the list of "dependent" tables in contact with a given "reference" table.

Parameters:
in_reference_tableThe "reference" table.
Returns:
the method returns the list of "dependent" tables in contact with a given "reference" table.

Definition at line 230 of file Database.java.

Referenced by org.dbview.db.structure.Database.getDependentTables(), and org.dbview.db.structure.Database.getNeighborhood().

ArrayList<Table> org.dbview.db.structure.Database.getDependentTables ( String  in_reference_table_name) throws Exception

This method returns the list of "dependent" tables in contact with a given "reference" table, identified by its name.

Parameters:
in_reference_table_nameThe "reference" table_name.
Returns:
This method returns the list of "dependent" tables in contact with a given "reference" table, identified by its name.

Definition at line 245 of file Database.java.

String org.dbview.db.structure.Database.getName ( )

Return the name of the database.

Returns:
The method returns the name of the database.

Definition at line 141 of file Database.java.

Referenced by org.dbview.db.structure.Table.getDatabaseName().

ArrayList<Table> org.dbview.db.structure.Database.getNeighborhood ( Table  in_table) throws Exception

This method returns the neighborhood of a given table.

Parameters:
in_tableThe table.
Returns:
The method returns the list of tables in the neighborhood of the given table.
Warning:
The returned list does not contain the given table.

Definition at line 318 of file Database.java.

Referenced by org.dbview.db.structure.Database.getNeighborhood(), and org.dbview.db.structure.Database.zoomAroundByTables().

ArrayList<Table> org.dbview.db.structure.Database.getNeighborhood ( String  in_table_name) throws Exception

This method returns the neighborhood of a given table, identified by its name.

Parameters:
in_table_nameThe name of the table.
Returns:
The method returns the list of tables in the neighborhood of the given table, identified by its name.
Warning:
The returned list does not contain the given table.

Definition at line 340 of file Database.java.

String org.dbview.db.structure.Database.getNonTableTag ( ) throws Exception

This method returns an identifier that does not represent a table's name. Each call to this method returns a unique identifier.

Returns:
The method returns an identifier that does not represent a table's name.
Exceptions:
Exception

Definition at line 576 of file Database.java.

ArrayList<Table> org.dbview.db.structure.Database.getReferenceTables ( Table  in_dependent_table) throws Exception

This method returns the list of "reference" tables in contact with a given "dependent" table.

Parameters:
in_dependent_tableThe "dependent" table.
Returns:
the method returns the list of "reference" tables in contact with the given "dependent" table.

Definition at line 200 of file Database.java.

Referenced by org.dbview.databaseExporters.dot.DotLight.export(), org.dbview.databaseExporters.dot.DotMedium.export(), org.dbview.databaseExporters.dot.DotFull.export(), org.dbview.db.structure.Database.getNeighborhood(), org.dbview.db.structure.Database.getReferenceTables(), and org.dbview.db.structure.Database.jgrapht().

ArrayList<Table> org.dbview.db.structure.Database.getReferenceTables ( String  in_dependent_table_name) throws Exception

This method returns the list of "reference" tables in contact with a given "dependent" table, identified by its name.

Parameters:
in_dependent_table_nameName of the "dependent" table.
Returns:
This method returns the list of "reference" tables in contact with a given "dependent" table, identified by its name.

Definition at line 219 of file Database.java.

ArrayList<FieldToFieldJoin> org.dbview.db.structure.Database.getRelationsFromReferenceToTarget ( Table  in_dependent_table,
Table  in_reference_table 
) throws Exception

This method returns the list of relations from a given "dependent" table to a given "reference" table.

Parameters:
in_dependent_tableThe "dependent" table.
in_reference_tableThe "reference" table.
Returns:
The method returns the list of relations from the given "dependent" table to the given "reference" table.
Remarks:
A relation is a global link between two tables, while a join is a link between two fields.

Definition at line 258 of file Database.java.

Referenced by org.dbview.db.structure.Database.__getRelationsToTable(), org.dbview.databaseExporters.dot.DotFull.export(), and org.dbview.db.structure.Database.getRelationsFromReferenceToTarget().

ArrayList<FieldToFieldJoin> org.dbview.db.structure.Database.getRelationsFromReferenceToTarget ( String  in_dependent_table_name,
String  in_reference_table_name 
) throws Exception

This method returns the list of relations from a given "dependent" table (identified by its name) to a given "reference" table (identified by its name).

Parameters:
in_dependent_table_nameName of the dependent table.
in_reference_table_nameName of the reference table.
Returns:
The method returns the list of relations from then given dependent table to the given reference table.

Definition at line 306 of file Database.java.

Table org.dbview.db.structure.Database.getTable ( String  in_name)

Return a table.

Parameters:
in_nameNane of the table to return.
Returns:
The method returns a table. If the table does not exist in the database, then the method returns the value null.

Definition at line 152 of file Database.java.

Referenced by org.dbview.db.structure.Database.getDependentTables(), org.dbview.db.structure.Database.getNeighborhood(), org.dbview.db.structure.Database.getNonTableTag(), org.dbview.db.structure.Database.getReferenceTables(), org.dbview.db.structure.Database.getRelationsFromReferenceToTarget(), and org.dbview.db.structure.Database.zoomAroundByNames().

ArrayList<Table> org.dbview.db.structure.Database.getTables ( )

Return the list of all tables in the database.

Returns:
The method returns the list of all tables in the database.

Definition at line 163 of file Database.java.

Referenced by org.dbview.db.structure.Database.__getRelationsToTable(), org.dbview.databaseExporters.dot.AbstractDatabaseExporter.AbstractDatabaseExporter(), org.dbview.db.structure.Database.generateRelations(), and org.dbview.db.structure.Database.jgrapht().

int org.dbview.db.structure.Database.getTableToTableRelationType ( Table  in_dependent_table,
Table  in_reference_table 
) throws Exception

This method returns the type of relation between to given tables.

Parameters:
in_dependent_tableThe "dependent" table.
in_reference_tableThe "reference" table.
Returns:
The method returns the type of relation between the given dependent table and the given reference table. It can be:
  • SOFT_AND_HARD_LINK
  • SOFT_LINK
  • HARD_LINK

Definition at line 286 of file Database.java.

Referenced by org.dbview.databaseExporters.dot.DotLight.export(), org.dbview.databaseExporters.dot.DotMedium.export(), and org.dbview.databaseExporters.dot.DotFull.export().

UndirectedGraph<Table, JgraphtTableToTableEdge> org.dbview.db.structure.Database.jgrapht ( ArrayList< Table in_tables) throws Exception

This method returns the JGRAPHT representation of a given set of tables.

Parameters:
in_tablesSet of tables. If the parameter's value is null, then the model is built using all the database's tables.
Returns:
The method returns the JGRAPHT representation of the given set of tables (or the complete set of tables, if the specified set is null).
See also:
http://jgrapht.org/
Exceptions:
Exception

Definition at line 527 of file Database.java.

String org.dbview.db.structure.Database.toString ( )

This method produces a textual representation of the database.

Returns:
The method produces a textual representation of the database.
Remarks:
This method is used for debugging.

Definition at line 555 of file Database.java.

ArrayList<Table> org.dbview.db.structure.Database.zoomAroundByNames ( ArrayList< String >  in_table_names,
Integer  in_level 
) throws Exception

This method returns the neighborhood of a given list of tables, identified by their names. The size of the neighbourhood area is defined by an integer (the zoom level).

Parameters:
in_table_namesThe list of tables' name.
in_levelZoom level (starts at 0).
Returns:
The method returns the neighborhood of the given list of tables, identified by their names.
Exceptions:
Exception

Definition at line 427 of file Database.java.

ArrayList<Table> org.dbview.db.structure.Database.zoomAroundByTables ( ArrayList< Table in_tables,
Integer  in_level 
) throws Exception

This method returns the neighborhood of a given list of tables. The size of the neighbourhood area is defined by an integer (the zoom level).

Parameters:
in_tablesThe list of tables.
in_levelZoom level (starts at 0).
Returns:
The method returns the neighborhood of the given list of tables.
Exceptions:
Exception

Definition at line 355 of file Database.java.

Referenced by org.dbview.db.structure.Database.zoomAroundByNames().


Member Data Documentation

Integer org.dbview.db.structure.Database.__n = 0 [static, private]

This value is used by the method that generates unique names that don't represent tables.

Definition at line 47 of file Database.java.

Referenced by org.dbview.db.structure.Database.getNonTableTag().

This hash contains all relations between tables.

  • Hash's key: The "dependent" table.
  • Hash's value: A hash that lists all relation from the (dependent) table used as key. Relations are grouped by "reference" tables.
    • Hash's key: The "reference" table.
    • Hash's value: Relations' "meta data" container. See class MetaData.

Definition at line 121 of file Database.java.

Referenced by org.dbview.db.structure.Database.__getRelationsFromTable(), org.dbview.db.structure.Database.__getRelationsToTable(), org.dbview.db.structure.Database.generateRelations(), org.dbview.db.structure.Database.getDependentTables(), org.dbview.db.structure.Database.getReferenceTables(), org.dbview.db.structure.Database.getRelationsFromReferenceToTarget(), and org.dbview.db.structure.Database.getTableToTableRelationType().

Hashtable<String, Table> org.dbview.db.structure.Database.__tables = new Hashtable<String, Table>() [private]

This hash table lists all database's tables.

  • Hash's key: The name of the table.
  • Hash's value: The table which name is defined as key.

Definition at line 106 of file Database.java.

Referenced by org.dbview.db.structure.Database.addTable(), org.dbview.db.structure.Database.getTable(), org.dbview.db.structure.Database.getTables(), org.dbview.db.structure.Database.toString(), and org.dbview.db.structure.Database.zoomAroundByTables().

This constant represents a "hard relation".

Remarks:
A hard relation contains only hard joins. This type of join is defined by a table's constraints only.

Definition at line 97 of file Database.java.

Referenced by org.dbview.db.structure.Database.__getRelationsFromTable(), org.dbview.databaseExporters.dot.AbstractDatabaseExporter._relationColor(), and org.dbview.db.structure.FieldToFieldJoin.type().

This constant represents a maximum cardinality of 1 (for join).

Definition at line 62 of file Database.java.

Referenced by org.dbview.db.structure.Database.__getRelationsFromTable(), and org.dbview.db.structure.FieldToFieldJoin.__getSymbol().

final int org.dbview.db.structure.Database.MAX_N = -1 [static]

This constant represents a maximum cardinality of N (for join).

Definition at line 67 of file Database.java.

Referenced by org.dbview.db.structure.Database.__getRelationsFromTable(), and org.dbview.db.structure.FieldToFieldJoin.__getSymbol().

This constant represents a minimum cardinality of 1 (for join).

Definition at line 57 of file Database.java.

Referenced by org.dbview.db.structure.Database.__getRelationsFromTable(), and org.dbview.db.structure.FieldToFieldJoin.__getSymbol().

This constant represents a "mixed relation". This type of relation is a mix between soft and hard joins.

Remarks:
A soft relation contains only soft joins. A soft join is defined by foreign keys' names only. You can find this type of joins in MyIsam (MySql) tables, for example.
A hard join is defined by the table's constraint.

Definition at line 90 of file Database.java.

Referenced by org.dbview.db.structure.Database.__updateMetaRelationType(), and org.dbview.databaseExporters.dot.AbstractDatabaseExporter._relationColor().

This constant represents a "soft relation".

Remarks:
A soft relation contains only soft joins. A soft join is defined by foreign keys' names only. You can find this type of joins in MyIsam (MySql) tables, for example.

Definition at line 81 of file Database.java.

Referenced by org.dbview.db.structure.Database.__getRelationsFromTable(), org.dbview.databaseExporters.dot.AbstractDatabaseExporter._relationColor(), and org.dbview.db.structure.FieldToFieldJoin.type().

This constant represents an unknown type of relation.

Remarks:
Please note that this value is used for initialization only. Once the database is loaded, no link should present this value.

Definition at line 74 of file Database.java.

Referenced by org.dbview.db.structure.Database.__updateMetaRelationType(), org.dbview.db.structure.Database.getTableToTableRelationType(), and org.dbview.db.structure.FieldToFieldJoin.type().


The documentation for this class was generated from the following file: