Which of the following represents an aggregate relationship (has-a)?
- Parent and child.
- Animal and dog.
- teacher and computer
- phone and fax machine
- All of the bove
The correct answer is 3. But why is not 1 also an aggregate relationship?
Which of the following represents an aggregate relationship (has-a)?
The correct answer is 3. But why is not 1 also an aggregate relationship?
It depends on your application. Using UML specification:
Sometimes a Property is used to model circumstances in which one instance is used to group together a set of instances; this is called aggregation.
whereby there are different possibilities:
Now, the key difference between composition and aggregation is that "in composition, when the owning object is destroyed, so are the contained objects", while aggregation "does not imply ownership" (see wikipedia).
The child can not survive without its parent in this scenario. Whether this makes sense or not depends on the used model.