Difference between Aggregation and Composition
Aggregation vs Composition: Key statistics
Example of Composition
The folder could contain many files, while each File has exactly one Folder parent. If a folder is deleted, all contained files are removed as well. In a composite aggregation, an object may be a part of only one composite at a time.
Example of Aggregation
For example, your car consists of wheels, engine, gearbox, steering, and the main body, etc. It is an assembly, and the other parts are its constituents. Here, car to the wheel is one Aggregation, car to the engine is another aggregation, car to gearbox another, and so on. This type of pairing helps you to define the multiplicity of the constituent part within the assembly as its outcome. The number of objects can also be depicted. A car needs a wheel to function correctly. However, we cannot say the same with a car. The same logic can be applied to bike, bicycle, or any other vehicle but not a particular car. Here, the wheel object is meaningful even without the car object. It is known as an aggregation relationship.