Welcome to the CSC Q&A, where you can get help (and share your knowledge) about computer science!

What's the difference between an association, aggregation, and composition for UML diagrams?

+10 votes
When showing the relationships for classes an association is for a has-a relationship but what kind of relationship does a composition and aggregation represent between classes?
asked Sep 11, 2016 in CSC 285 (F16) by Jared Haeme (285 points)

2 Answers

+1 vote
An aggregation represents a whole-part relationship. If you look on page 307, it's symbolized by a college and its buildings. In other words, a college is incomplete without its buildings. A composition indicates strong ownership (the two objects cannot exist without each other), and is symbolized by a college and its courses. A college cannot exist without courses, and vise versa.
answered Sep 11, 2016 by Eric Sheidler (100 points)
+1 vote
Composition and aggregation are both special types of association.  They could still be a "has-a" relationship.  Or perhaps "contains".  Or "is composed of".
answered Sep 11, 2016 by Forrest Stonedahl (3,438 points)