
- UML - Home
- UML - Overview
- UML - Challenges & Real-world Applications
- UML - Building Blocks
- UML - Architecture
- UML - Modeling Types
- UML - Basic Notations
- UML - Standard Diagrams
- UML - Class Diagram
- UML - Object Diagram
- UML - Component Diagram
- UML - Deployment Diagram
- UML - Use Case Diagram
- UML - Interaction Diagram
- UML - Statechart Diagram
- UML - Activity Diagram
- UML - Communication Diagram
- UML - Timing Diagram
- UML - Sequence Diagram
- UML - Collaboration Diagrams
- UML - Profile Diagram
- UML - Sequence Vs. Collaboration Diagrams
- UML - Sequence Vs. Collaboration Vs. Communication Diagrams
- UML - Association Vs. Aggregation Vs. Composition
- UML - Interaction Overview Diagram
- UML - Composite Structure Diagram
- UML - Object Constraint Language
- UML - Managing Models
- UML - Summary
- UML Useful Resources
- UML - UML Interview Questions & Answers
- UML - Useful Resources
- UML - Knowledge Test
UML - Association vs. Aggregation vs. Composition
Let us consider the differences and similarities between the classes of the following objects: pets, dogs, tails, and owners.

we can see the following relationships
Owners and Pets (Association) − Owners provide food to pets, and pets provide comfort to owners. This is an example of association.
Tails in Dogs and Cats (Aggregation/Composition) − A tail belongs to both dogs and cats, representing aggregation or composition.
Cats as Pets (Inheritance/Generalization) − A cat is classified as a type of pet, which represents inheritance or generalization.
UML Relationships: Association, Aggregation, and Composition
The diagram below illustrates three types of association links: association, aggregation, and composition. These concepts will be explored further in this UML guide.

Association
When two classes within a model must interact, a connection between them is symbolized by an association (link).
- The association is depicted as a line connecting two classes, with an arrow to indicate navigation direction. If arrows appear on both ends, it represents a bidirectional association.
- We can represent multiplicity in an association by adding a multiplicity of adornments to the line. For instance, a Student may have one or more Instructors.
A single student has multiple teachers −

Example
The aggregation link does not imply Class A owns Class B or that there is a parent-child link. It emphasizes that Class B may have other holders apart from Class A.

Composition
Composition suggests that the child cannot exist independently from the parent. For example, a House (parent) and a Room (child). If the House is removed, the Rooms are removed too.
Example
We use a composition link when there is a strong lifecycle connection between Class A and Class B, meaning the deletion of Class A will also delete Class B.

Both aggregation and composition are specialized forms of association. The primary difference between them lies in the independence of the child class from the parent class.
Differences Between Association, Aggregation, and Composition
The following table shows the key differences between association, aggregation, and composition in UML −
Aspect | Association | Aggregation | Composition |
---|---|---|---|
Definition | Represents when two classes in a model need to communicate. | A parent class "owns" an object of another class, but the child can exist independently of the parent. | A parent class "owns" a child object, and the child cannot exist without the parent. |
Life Dependency | No life dependency between the associated classes. | The child class continues to exist even when the parent is deleted. | The child class cannot exist if the parent is deleted. |
Types of Associations | Includes one-to-one, one-to-many, many-to-one, many-to-many | Includes one-to-one, one-to-many, many-to-one, many-to-many | Includes one-to-one, one-to-many, many-to-one, many-to-many |
Example | Owners and pets, pets please owners. | Class (parent) and Student (child). | House (parent) and Room (child). |
To summarize, association refers to a general relationship where one class uses the functionalities of another class. It is referred to as composition when a parent class owns a child class object, and the child class object cannot exist without the parent. If the child class can exist without the parent, then it is called aggregation.