DbTable Interface

This interface is used to describe and provide common implementations to any table in a database.

Check for tables compatibility

Table compatibility, as defined in Gda Vala Extensions, is a set of tests to garanty one table is able to copy data to another.

The following tests are performed when A.compatible(B) is called:

  1. Fields in table A are located in table B

  2. Fields in table A are compatible with the one in table B

Field compatibility are performed by compatible() method defined in DbFieldInfo interface.

This codes checks for compatibility between two tables. create_definition() is a user defined method to initiate a table by adding fields definitions that will be used template.
Table a = new Table ();
a.name = "user2"; // set to a database's table name
a.connection = connection;
a.update (); // Get definition from database metadata
Table b = new Table ();
b.name = "users"; // set to a database's table name
b.connection = connection;
b.update (); // Get definition from database metadata
if (a.compatible (b))
	stdout.printf (@"You can copy data from table $(a.name) to table $(b.name)");
			

Check for tables equivalent

Table equivalency, as defined in Gda Vala Extensions, is a set of tests to verify that most important parts of a hard coded table (template) definition are present in other table. Then is recomended to check equivalency of a hard coded definition, agains a database table that had been updated using update() method.

The following tests are performed when A.equivalent(B) is called:

  1. Fields in table A are located in table B

  2. Fields in table A are equivalent with the one in table B

Field equivalency are performed by equivalent() method defined in DbFieldInfo interface.

This codes checks for equivalency between two tables.
Table a = new Table ();
a.name = "pre-defined";
create_definition (a); // See at Table class to see how define a table
Table b = new Table ();
b.name = "users"; // set to a database's table name
b.connection = connection;
b.update (); // Get definition from database metadata
if (a.equivalent (b))
	stdout.printf (@"Database table $(b.name) is based on template table $(a.name)");