gASQL manual | ||
---|---|---|
<<< Previous | Next >>> |
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:
the relation from the salesman id to the customer's 'served_by' field: the customer is 'served by' the sales man it references.
the relation from the orders id and the order_contents: each entry in the order_contents table can only exist if there is a corresponding order which it references.
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.
Creation and deletion of relations
For every table and view in the database, it is possible to open a properties dialog which contains a subpart (the lower part of the dialog) to manage relations between table's fields.
When a table (or view) has its properties box displayed, all the information is centered on that table (or view): the presented relations are the ones which are about a field of the table in them. The relations edited in one properties box, if they also appear in another properties box, will be automatically updated, so all the information in all the properties are always up to date.
To manage all the relations related to a field, simply select a field from the ones at the top of the dialog. The lower part of the dialog then shows the selected field and the relations related to that field: the ones shown on the left are the links from something (either a table's field or a sequence) and the ones on the right represent links from the selected field to the table's field shown.
Below is a screen shot of the properties dialog of the 'order_contents' table. As the order_id field is selected in the upper part of the dialog, the lower part shows the relation in which this field is engaged (a relation from the 'orders' table and 'id' field to this selected field).
Global view of the relations
This dialog allows relations to be displayed all at once (and is in sync with the properties dialog mentionned in the previous section); the relations cannot be edited (either created or removed) from that dialog (this is an improvment that may be done in a future version).
Using it is simple: the tables, views and sequences are all listed in the left part of the dialog, and when selected will be displayed (or hidden) on the right part of the dialog, along with the relations. Sequences appear as elliptical objects and tables or views as rectangular ones. Only the relations between two objects visible will be displayed using arrows.
It is possible to move the objects to better organize the display. The positions will be saved when the session is closed, and a hidden object will reappear at the same place it was before being hidden.
Here is a screen shot of a global dialog for relations:
<<< Previous | Home | Next >>> |
Menus description | Data manipulation queries |