Chapter 3. Tables relations

3.1. Generalities on relations

Relations are the way the tables are linked to each other. They can be considered as the result, in the database structure, of an Entity-Relationship design.

gASQL considers two kinds of relations (sometimes refered to as links): relations between two tables' fields, and relations between a sequence and a table's field. The two can be understood as 'an object A has an influence on an object B' where there is a relation from A to B.

Relations between two fields of two different tables will be used to specify joins in a selection, and can correspond (but don't have to) to foreign keys. For example in the 'Sales' database as example, some examples or relations include:

If sequences are supported by the database, relations are also possible from sequences to fields, which means that the field will get its values from the sequence (and thus guarantees a unique value for each field, to be used with primary keys).

It is important to take the time to declare all the possible relations in the database as gASQL will use this information when creating queries to automatically take care of the joins between tables.

Relation cardinality are not yet supported: there is no information about the kind of link which is represented: 1:1, 1:N, etc. This feature may be inserted in future releases if needed.

gASQL uses one kind of window to create and delete relations, and one window to display a summary of all the relations for some (or all) of the tables and views in the database.