How to describe a contained map in UML class diagram?

You can use a qualified association:

┌──────────┐             1 ┌───────┐
│ MyServer │Key│───────────│ Value │
└──────────┘               └───────┘

See: http://etutorials.org/Programming/UML/Chapter+6.+Class+Diagrams+Advanced+Concepts/Qualified+Associations/ (cause it is hard to draw using ASCII)

Note also that a qualified association changes the multiplicity:

┌──────────┐          0..* ┌───────┐
│ MyServer │───────────────│ Value │
└──────────┘               └───────┘

┌──────────┐             1 ┌───────┐
│ MyServer │Key│───────────│ Value │
└──────────┘               └───────┘

The top illustrates an association from a server to 0-n values. By contrast, the qualified association says that any given key will be associated with only one value, and that you can’t have a key an absent value.

Leave a Comment