Table Relations

For the tables where we defined fields intended to refer to data in other tables for lookups and validation, we must define the relationships in the referring tables. Sometimes those relationships are complicated, dependent on other values within the record.

In Table 50003, Playlist Line, we have the field No.. If the Type field contains Resource, then the No. field should contain a Resource No.. If the Type field contains Show, then the No. field should contain a Radio Show No.. And, if the Type field contains Item, the No. field should contain an Item No. The pseudo-code (approximate syntax) for that logic can be written as follows:

    IF Type = 'Resource' THEN No. := Resource.No. 
ELSE IF Type = 'Show' THEN No. := Radio Show.No.
ELSE IF Type = 'Item' THEN No. := Item.No.

Fortunately, a tool built into the C/SIDE editor makes it easy for us to build that complex logic in the TableRelation property. When we click on the TableRelation property, then click on the ellipsis button (three dots), we get a Table Relation screen we can use to construct the necessary logic structure:

When we exit the Table Relation screen by clicking on the OK button, the TableRelation line looks like the following:

Table 50004, Playlist Item Rate, has a similar TableRelation requirement for the Source No. field in that table. In this case, if Source Type = Vendor then the Source No. field will refer to the Vendor No. field or if the Source Type = Customer then the Source No. field will refer to the Customer No. field:

When we exit the Table Relation screen this time (by clicking on the OK button), the TableRelation line looks like the following:

If in the process of making these changes (or some future changes), we realize that we need to change the data type of a field and try to do so, we may get this error message:

The intent of this message is to keep us from unintentionally deleting or corrupting data through a change in the table definition. After checking that we really aren't going to make that mistake, perhaps making a backup of the data about to be affected, we can override the system's error checking and force the change to be done by setting the Synchronize Schema ... field to Force in the Save Changes screen, as shown in the following screenshot: