If your COBOL application has data from several different business units, stored in different COBOL data files on the same machine, you can connect them to the same table definition.
Each table connection has a different table name that must be used in the SQL statement to indicate which data file is to be accessed. Sometimes, however, it is desirable to query the data in all business units. While it is possible to use separate table connections and to combine the resulting rows in the ODBC application, Relativity uses multi-file table support to perform this process automatically and at a record level, making use of the file keys.
The combining of records can occur in one of two ways. Either the records from each individual file are processed into rows separately, with each file being processed completely before proceeding to the next file, or the records from the individual files are read using the same key on each file and merged into one sorted record stream as if they were from a single file.
To control which method to use, and, in the ODBC application, to be able to distinguish the business unit from which the row originated, a special file definition item called a "file label" is added to the file's FD using the Designer. A given FD may have only one file label item. A file label item can have a column defined on it, and this column will be part of the indexes defined on the table. Assuming that columns are completely defined on all the file key parts, at least two indexes will be created for each file key: one with the file label column as the most significant part of the index, and one with the file label column as the least significant part of the index. If a query uses the index that has the file label column as the most significant column, then rows from each file will be grouped together. If a query uses the index that has the file label column as the least significant column, then the rows from each file will be returned merged together.
In Relativity, consider a table based on two files. Using the index that returns rows grouped together, the ODBC application would first see all the rows from the first file, and then the rows from the second. Using the index that merges the two files together, the ODBC application would see rows coming back from the two files mixed together.
When a COBOL data file is added to a multi-file table, it is assigned a value for its file label. This is the value that is returned in the file label column. Note that while it is usually desirable to assign the same file label value to all the files from the different business units, Relativity does not require or enforce this.