Today I Learned

Some of the things I've learned every day since Oct 10, 2016

109: Composition vs Aggregation in Has-a Relationships

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: