Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does a relation (aggregation, composition) replace an attribute?

Tags:

uml

I'm pretty new at UML modelling so bear with me.

Say I have a class with an attribute students that is a list of Student instances. I have set an aggregation relation to the Student class which is also in the diagram. Does this relation replace an attribute entry such as #students : Student[] in the container class, or can the attribute and relation co-exist?

Thanks in advance for any answers!

like image 857
Victor Avatar asked Jul 23 '11 00:07

Victor


2 Answers

Short answer: Can the attribute and relationship both exist? No...

But if your classes are software classes you may have many choices for showing them:

enter image description here

But if your classes are not sofware classes and you model the domain you should be more carefully to show an entity as an attribute or class. Generally if the entity is complex type, it is shown as seperate class. But that is not a rule: depends on context.

enter image description here

like image 93
Novalis Avatar answered Oct 21 '22 14:10

Novalis


An attribute helps to identify the structure of the object. Aggregation gives a high level overview that the object will contain one (or more) of another type. Neither replaces, but instead shows the relationship between the object types.

like image 26
Suroot Avatar answered Oct 21 '22 12:10

Suroot