An association is a set of two or more multivalued fields that are related such that the values are inter-dependent. For example, an order processing database might contain a file listing the items in each order. This would require a multivalued list of products and a corresponding multivalued list of quantities. A realistic data file may contain several associated sets of fields.
The query processor needs to know about this relationship. An association is defined by giving it a name which appears in field 7 of the C/D/E/I-type dictionary entry of each field in the association. Applications migrated to QM from some other multivalue systems may also have a phrase record with this name which contains a space separated list of the fields that make up the association though this is not required in QM.
Thus, starting from any one element of the association, its dictionary entry can be used to find the phrase record which, in turn, allows us to find all the members of the association.
Pick style A/S-type dictionary items use a different way to define associations. Reworking the example above based on an order processing system, one of the fields is chosen as the "controlling field" and others in the association are considered as "dependent fields". In this example, the customer came to the shop to purchase some specific part and then decided how many he wanted. He did not go to the shop with the intention of buying three of something and then deciding what product it would be. Thus, the part number controls the association.
For the controlling field, the association element of the dictionary item (field 4) contains a string such as "C;2;3;4" where the numeric components are the field numbers of the dependent data items There is no way to use field names here. For the dependent fields, field 4 of the dictionary record contains "D;1" where the numeric component is the field number of the controlling field.
Internally, QM converts the controlling/dependent field definition into an association named __n where n is the controlling field number. This name can be used in field 7 of a C/D/E/I-type entry if the dictionary has mixed data type definition styles. Alternatively, as an extension to the Pick style A/S-type items, QM also allows field 4 to contain an association name. Thus it is possible to associate field definitions of any type.
For compatibility with some other multivalue database products, the ASSOC.UNASSOC.MV mode of the OPTION command can be used to make the query processor treat all multivalue fields that are not in defined associations as being associated together. Reliance on this instead of properly defined associations is discouraged as it can lead to unexpected effects, especially with exploded sorts, and hides the relationship when the dictionary is used as the reference model of the data structure.