UML Unique and Ordered Constraint

The multivalued attributes can be further specified using uniqueness and order modifiers. The modifiers are displayed in the braces {} after the attribute specification.

UML Unique Constraint

The unique modifier ensures that the values in the collection of this attribute are unique. The collections with unique values are Set or Ordered Set.

The nonunique modifier allows using multiple identical values within the collection. The nonunique collections of values are Sequence and Bag.

UML Ordered Constraint

The ordered modifier requires an exact order of the values from the collection. The ordered collections are Ordered Set and Sequence.

The unordered modifier says that the values can be returned in any order (the order can even change between calls). The unordered collections are Set and Bag.

Collections of unique and ordered values in UML
Collections of unique and ordered values in UML

How to set unique/nonunique constraint

There are two ways how to set unique and nonunique modifiers for the attribute:

  • Right-click on the attribute, choose Properties and select Unique or Nonunique from the Uniqueness combo box. Confirm the dialog using the OK button.
  • Edit the attribute in the diagram editor and type unique or nonunique into braces {} (the constraint definition).

How to set ordered/unordered constraint

There are two ways how to set ordered and unordered modifiers for the attribute:

  • Right-click on the attribute, choose Properties and select Ordered or Unordered from the Ordered combo box. Confirm the dialog using the OK button.
  • Edit the attribute in the diagram editor and type ordered or unordered into braces {} (the constraint definition).

New Comment

Comment