TreeCube

Archive for the 'UML' category

n-ary associations in UML

July 22, 2008 12:19

I just found that it is possible to modelize n-ary association in UML. I use uml all the time and never saw a class diagram with a n-ary association, but a couple of weeks ago, in a meeting, we were discussing a conceptual model representing a database schema and we were wondering if it was possible to model that in UML. So, yes, it is possible.

I didn’t found the reference in the uml specification, but I did found it in the book “The Unified Modeling Language Reference Manual, second edition” by James Rumbaugh, Ivar Jacobson and Grady Booch.

Ternary association in UML

Definition: An association among three or more classes.

Semantics: Each instance of the association is an n-tuple of values, one from each of the respective classes. A single class may appear in more that one position in the association, but the values in the different positions are independent and need not be the same object.

About the multiplicity, the authors say the following: “the multiplicity is defined with respect to the other n-1 ends. For example, given a ternary association among classes (A,B,C), the multiplicity of the C end states how many C objects may appear in association with a particular pair of A and B objects.

I guess it would be hard to enforce something like that in java or c++, but in the context of a database, that kind of constraits is easy to enforce with referential integrity, uniqueness and constraint (like oracle constraint). Maybe it is why n-ary associations are not widely used…