MPL allows you import the elements for an index directly from a database. In the INDEX section, where you define the index, enter the keyword DATABASE after the assignment symbol followed by parentheses containing the table name and the column/field name you want to import from.
INDEX depot := DATABASE("Depots","DepotID");
In the above example, MPL will open the database table Depots, locate the column DepotID, and then read in the entries for the index depot. In most cases the imported indexes are the key fields for the table.
To make sure there are no name conflicts when sending the problem to the solver, keep at least the first three characters of the named subscripts distinct. If that is difficult, you can abbreviate the names by importing another column from the database table containing shorter names. To import the short name column enter the keyword BECOMES followed by the column name inside the parenthesis. Here is an example:
INDEX depot := DATABASE("Depots", "DepotName", BECOMES "DepotID");
It is not always desirable to have the same subscript length for all indexes in the model. Therefore you can use a different length for each named index by following the index definition with a colon and a new length. For example:
INDEX depot := DATABASE("Depots","DepotID"):4;
This definition sets the subscript length for the month index to 4.
In some instances you do not want to create the index with all the elements that are in the table. In that case, you can enter the keyword WHERE followed by a condition on one of the columns. Here is an example:
INDEX depot := DATABASE("Depots", "DepotID", WHERE Region="NorthWest");
For further information on importing indexes please refer to Chapter 11.1: Import Indexes from Database