109: Composition vs Aggregation in Has-a Relationships
July 10, 2017
Posted by on
There are two different types of has-a relationships, composition and aggregation, distinguished by whether the child object belonging to the parent object can belong to more than just that parent. In essence, composition implies ownership while aggregation does not.
For example, a university has departments. These departments belong to no other university and if the university is ceases to exist, so do they. This exemplifies a composition relation.
By contrast, a department has professors, but a given professor may belong to more than one department and will usually not cease to exist when the department does. This is instead an aggregation relation.