Go to the first, previous, next, last section, table of contents.


Relational constraints

The relational specification file captures a portion of the relational database definition not covered by the table definitions. It defines the links between the tables and the tables that should be treated as dictionaries. The semantics of this description is rather limited compared to the full power of the relational model. However it allows to do simple things that would otherwise be quite complex to implement.

The general structure of a relation file is an ASCII file where lines beginning with a dash (#) are ignored as well as empty lines.

The name of the relation file is relations.spec and will be found either in the current directory or in the directory pointed by the CONFIG_DIR environment variable.

`Link between two tables'
The two tables are linked together thru a n-1 or n-n relation. The line describing this relation is structured as follows:
table1:field1   table2:field2
It means that table1 is linked to table2 using the values in field1 and field2.
`Dictionary with a single possible value'
Two tables are linked thru a n-1 relation. One table, the dictionary, provides a list of possible values and the other table uses this list as dictionary. The line describing this relation is structured as follows:
table:field     dict:key        L       dict:label
The dictionary is the dict table. The table table refers to it by the field field that contains a value linked to a value of the key field of the dict table. The third field always contain L indicating that this line describe a List. The last field specify that the user readable value associated to key can be found in the label field.
`Dictionary with a multiple value'
This is a bit more complex here since three tables are involved in a multiple value dictionary. The table that contains the list of possible values, the table that contains the records and the table that link those two. The line describing this relation is structured as follows:
table:field     dict:key        M       dict:label      table2dict
The dictionary is the dict table. The field field of table is a fake field name that will be used to refer to the list of the values associated to a single record of table if necessary. The table must contain a field named rowid that is the primary key of the table. The table2dict table must contain two fields named table and dict. The table2dict.table field refer to the table.rowid field and the table2dict.dict field refer to the dict.key table.

Here is an example relations.spec file:

#
# Table dependencies
#
start:societe                   societe:rowid
personne:societe                societe:rowid
marque:societe                  societe:rowid
lecteur:personne                personne:rowid
produitsnouveaux:personne       personne:rowid
produitsnouveaux:societe        societe:rowid
images:produitsnouveaux         produitsnouveaux:rowid
#
# Dictionaries
#
#
# Societe table
#
societe:ca              ca:rowid                L       ca:libelle
societe:effectif        effectif:rowid          L       effectif:libelle
societe:statut          statut:rowid            L       statut:statut
societe:activite        activite:rowid          L       activite:activite
societe:pays            pays:rowid              L       pays:pays
societe:naf             naf:rowid               L       naf:libelle
societe:q               q:rowid                 M       q:q     q2societe
#
# Lecteur table
#
lecteur:navigateur      navigateur:rowid        L       navigateur:navigateur
lecteur:os              os:rowid                L       os:os
lecteur:provider        provider:rowid          L       provider:provider
lecteur:connexion       connexion:rowid         L       connexion:connexion
#
# Personne table
#
personne:pays           pays:rowid              L       pays:pays
personne:profil         profil:rowid            L       profil:profil


Go to the first, previous, next, last section, table of contents.