3.4.3. Modes table

The modes table exists to list all the modes available in the model’s network, and its main role is to support the creation of graphs directly from the SQLite project.

The modes table has three fields, being the mode_name, description and mode_id, where mode_id is a single letter that is used to codify mode permissions in the network, as further discussed in Network.

An example of what the contents of the mode table look like is below:

Link examples

3.4.3.1. Consistency triggers

As it happens with the links and nodes table (Network consistency behaviour), the modes table is kept consistent with the links table through the use of database triggers

3.4.3.1.2. Directly changing the modes field in the nodes table

A trigger guarantees that the value being inserted in the field is according to the values found in the associated links’ modes field. If the user attempts to overwrite this value, it will automatically be set back to the appropriate value.

3.4.3.1.4. Editing a mode in the modes table

Whenever we want to edit a mode in the modes table, we need to check for two conditions:

  • The new mode_id is exactly one character long

  • The old mode_id is not still in use on the network

For each condition, a specific trigger was built, and if any of the checks fails, the transaction will fail.

The requirements for uniqueness and non-absent values are guaranteed during the construction of the modes table by using the keys UNIQUE and NOT NULL.

3.4.3.1.5. Adding a new mode to the modes table

In this case, only the first behaviour mentioned above on Editing a mode in the modes table applies, the verification that the mode_id is exactly one character long. Therefore only one new trigger is required.

3.4.3.1.6. Removing a mode from the modes table

In counterpoint, only the second behaviour mentioned above on Editing a mode in the modes table applies in this case, the verification that the old mode_id is not still in use by the network. Therefore only one new trigger is required.