Define Many To Many (M2M)

Using the Define Many To Many (M2M) option it is possible to define multiple relationships between tables and Views within tablesONLINE. The M2M facility allows you to do this, and to subsequently make use of these defined relationships. Defining an M2M relationship involves making an entry in the M2M table to associate a specific Data Table with a specific View and assign a unique Table Object name to that Data Table/View combination. Once that combination has been defined, a user does not have to know the name of the View or the name of the Data Table, it can simply be referred to using the Table Object name. tablesONLINE automatically searches the M2M table for an entry for the Table Object name, which indicates the table to be accessed and the appropriate View to be used.

To define an M2M relationship, select Option 9 – DEFINE M2M from the Define Table and View menu (see Figure 133). The system displays the Edit M2M Table-Identify Screen (see Figure 147).

Figure 147. The M2M Table – Identify Screen
The M2M Table - Identify Screen

This screen will already contain the Data Table Library, View Library and Table Object names for the table that contains the M2M information. If you wish to edit the information for an existing entry in the M2M table, you can insert the Table Object name in the Table Object field. This displays the Edit-Row screen for the selected Table Object. If no Table Object is specified in this field, the following Edit-Table screen will be displayed (see Figure 148).

From this screen (see Figure 148) you may select a row to edit or create a new Table Object. To create a new Table Object, place theNline command to the left of the row you wish to use as a template for the new entry and press <Enter>. This will display the Edit-Row screen. Here you must insert the name of the Table Object to be defined, as well as the names of the Data Table and associated View that are to be identified by that Table Object name. Once these fields have been completed, press <PF2> or <End>. You may continue to define additional entries, or you can use the <End> key to exit the Edit-Row screen and return to the menu.

Figure 148. The M2M Table – Edit-Table Screen
The M2M Table - Edit-Table Screen

Note:
  1. An entry is not required in the M2M table if: the relationship between the View and the Data Table is one-to-one, and the View and Data share the same name. This is the most common use of tablesONLINE.
  2. Entries in the M2M table to describe many Views for one Data Table are not needed. One can simply specify the same Data Table Name in each Supplementary View Information described earlier in this chapter.