-
Notifications
You must be signed in to change notification settings - Fork 0
Ordinals
The ordinal relationship models an ordered sequence of instances relationally, but unlike the other two relationship types (association and generalization), it is not formalized with referential attributes.
Instead an attribute with a type supporting order comparisons, such as an integer or rational number establishes an ascending or descending rank order.
Here is a model excerpt for ordinal relationship OR7 which establishes the vertical sequence of floors in
a building.
OR7
higher / lower, Floor
Height : I2
--
With the diagram snippet here:

And the grammar:
// Ordinal
ordinal_rel = ascend oform
ascend = INDENT highval SP '/' SP lowval ',' SP class_name EOL*
highval = phrase
lowval = phrase
oform = INDENT attr_name SP ':' SP itag EOL*
The relationship name must start with OR.
The first line after the relationship name defines the ascend / descend direction. This is not always
obvious from the naming, but the grammar indicates that the leftmost value is greater via the highval term
and the rightmost is lesser when determining order.
The bottom line selects the ordering attribute. That attribute must have a type that supports a greater than / less than order comparison.
There is then a colon symbol with a required single space on each side followed by the identifier name. Identifiers are named I, I2, I3 ... in Shlaer-Mellor models. The Floor class has two I and I2. In other words, each instance of Floor has both a unique name (G, L, 1, 2, ...) and a unique height (9.7 m, 11.5 m, ...).
Since the Height attribute is the only member of the I2 identifier, there is no choice in this case but to specify I2. But if you review the link at the top of this description, you'll see cases where an ordering attribute might participate in more than one identifier in which case it is important to specify the identifier that selects the intended partial ordering.
Copyright 2023-2026 © Leon Starr under MIT Open Source License