Question

This is about User and User Type relationship.

I have two classes User and UserType User has UserID, UserName, UserTypeID UserType as : TypeID, TypeName

One user can have only one User Type (TypeID1/TypeID2/TypeID3)

What could be UML class diagram notation to represent this? is it association or composition or aggregation?

This diagram has Car and car type as Association http://www.jetbrains.com/idea/features/screenshots/80/uml2.png

This diagram has plugin and plugin type as composition http://indico-software.org/raw-attachment/wiki/Dev/Technical/PluginSystem/Plugin%20System%20class%20diagram.png

Was it helpful?

Solution

Something like this?
enter image description here

or like this
enter image description here

it dependents buddy, the first solution is useful when the user type does some functionality itself, in other word its a class(member), while the second solution is just useful when there is some constant about user types.

OTHER TIPS

In order to know how to choose between association, composition or aggregation, you just have to answer at these two questions. 1) One is a part of the other? Yes => composition or aggregation, No => Association. 2) if you "delete" the container does the contain still exist? Yes => aggregation, No => Composition.

So as I understood your model you should model an association between User and UserType. Another solution would be to model an attribute on User with UserType as type.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top