Skip to content

Multiplicity

General

In UML, multiplicity describes how many instances of one class can be connected to an instance of another class through a given association. This relation is often expressed as a string showing the lower and upper bounds at the endpoints of a connection.

Let's look at an example from a hypothetical banking system. In our system, each customer must have at least one account at our bank and should not have more than five accounts in total. We could model this with the following UML association:

multiplicity from source to target

Multiplicity in a UML diagram

The text 1 .. 5 placed at the connection's end defines the range of possible accounts. To interpret this diagram, we would start reading from left to right :

One customer must have between one and five bank accounts

(note that the cardinality of the customer - "one" - is not explicitly modeled in the diagram)

But that's not all: We can also describe the relation between bank accounts and customers. Let's say that every account must belong to at least one customer, but for joint accounts, it could also have two owners:

multiplicity from target to source

Multiplicity in the reverse direction

Here we had to place the lower and upper bound on the other end, and consequently, we must now read from right to left:

One bank account must belong to one up to two customers*.

Again, the diagram does not contain the cardinality of "one" for the bank account.


Finally, we can combine both multiplicities into the same diagram to express both directions:

both multiplicities combined in one diagram

Both multiplicities combined in a single diagram

It's essential to keep in mind that this diagram combines the two expressions mentioned above into a single diagram, so the correct way to read it would be:

One customer has one to five bank accounts and one bank account belongs to one or two customers.

and not, as one would intuitively think

One or two customers have one to five bank accounts.

Multiplicity in UMLBoard

1.4

UMLBoard supports the definition of multiplicities for all associations (i.e., compositions, aggregations, and simple associations). By default, a newly created relationship does not have any multiplicity information stored, indicated by the grayed-out text none when moving the mouse over a connection.

no multiplicity

A connection in UMLBoard without any multiplicity set

1.13: Usage relations now also support multiplicity. This is especially helpful if you want to add additional text to the start/end of such a connection.

Start Editing

To add a multiplicity to a connection, click and hold (or double-click) on one of the none texts. The cardinality editor will open with the cursor always starting on the edit field for the lower bound.

nput field for entering cardinality

The cardinality editor can be opened by clicking on a multiplicity

Just enter any cardinality you want; UMLBoard does not set you any restrictions here. You can use any number or arbitrary string as input. If you only want to set a single boundary, you can also leave one cardinality edit field empty. Clearing both edit fields will remove the multiplicity from this end.

After entering any boundary, you have the following options:

  1. Pressing Enter will immediately confirm your input and close the editor.
  2. Pressing Tab instead will move the cursor to the following edit field:
    • If you are in a lower bound editor, it moves to the next upper bound
    • If you are in the upper bound editor, the cursor will move to the next (the target) multiplicity.
    • If you are already at the upper bound of the target multiplicity, this has no effect.
  3. Pressing Shift+Tab will move the cursor back to the previous multiplicity border. Using this shortcut, you can also switch back from the target to the source multiplicity.
  4. Pressing Esc will cancel your edit process and revert all values you entered since the editor opened.

complete editing multiplicity after last edit field

pressing the TAB key lets you navigate through the cardinalities

Context Menu

1.6

Starting with Version 1.6, you can also edit cardinalities by right-clicking on a relation's end point and choosing the Edit context menu entry.

Editing the cardinality via the context menu

Editing the cardinality via the context menu

Additional Notes

  • UMLBoard implements the following shortcuts from the UML Specification:
    • if lower and upper bound are the same, they will be written as a single value, so 1 .. 1 becomes just 1.
    • A multiplicity with a lower bound of 0 and an upper bound of * (unspecified) becomes just * instead of 0 .. *.
  • Currently, UMLBoard does not do any validity checks on the multiplicity, so you can enter anything you like. Therefore, something like a .. b or min .. max is very well possible.
  • Multiplicities in property syntax (like: wheels: Wheel [4]) are not yet supported but will be available in later versions. Please also remember that you will lose an association's multiplicity when you convert it into a property and back.

Tip

While it's not the intended use case, the multiplicity can also be used to display a source/target description for your association's ends. Just enter the text in the lower bound and keep the upper bound empty. As already mentioned, the multiplicity values are not validated, so you're free to enter anything you like here.