Attribute Clause

This clause associates one or more attributes with a relationship. To assign an attribute to a relationship, it must be previously defined. Attributes are useful in providing information specific to the connection you are making. In some cases the information is included in the business objects; in other cases, it is more appropriate to associate the information with the body of the connection. When making a connection, the user will fill in the attribute values.

For example, many different Assembly objects might use a Component object. The cost for installing the component into each assembly might differ considerably. Therefore, you could define an attribute called “Installation Cost” and associate it with the component relationship. Whenever a connection is made between a Component object and an Assembly object, the user can insert the cost associated with that connection.

Attributes can also be used in other relationship definitions or type definitions. Therefore, it is possible for the attribute to be contained within the object itself.

As another example, a Quantity attribute is assigned to an assembly object to track the number of components used. You also can assign the Quantity attribute to a relationship to track the number of times the component is required for an Assembly. Since the quantity of the component could differ from assembly to assembly, the relationship records the amount as part of its definition. When a specific Component object is connected to a particular Assembly object, the user automatically has a means of inserting the quantity information.

An Add Relationship command can have many or no Attribute clauses depending on the types of objects being connected and why. For example, the following command associates three attributes with the relationship named “Assembly Relationship”:

add relationship “Assembly Relationship”
   description “Identifies component objects used in an assembly object”
   attribute Quantity
   attribute Units
   attribute “Installation Cost”
   from
     type Assembly
     meaning “Is composed of”
     cardinality n
     minorrevision float
     clone none
   to
     type Component
     meaning “Is used by”
     cardinality n
     minorrevision float
     clone none;

Once this command is processed and the relationship is defined, you can create connections between instances of Component type objects and instances of Assembly type objects by using the Connect Businessobject command (as described in MQL Concepts: Making Connections Between Business Objects). These connections have three fields where the user can define the values for the attributes: Quantity, Units, and Installation Cost. Although the user is not required to enter values for the attributes, they are always available.

If you add an attribute that is part of an index, the index is disabled. For more information, see MQL Concepts: Indexes.