Composition Association
Database Essentials - Part 8
Division 1
Forward: In this part of the series, we look at what is called the Composition Association.
By: Chrysanthus Date Published: 4 Aug 2012
Introduction
Meaning of Composition Association
A composition is similar to an Aggregation. However in a composition you have classes that ultimately become the new class. In other words you have objects that ultimately become the new object. This means that you have tables whose main columns (properties), can be described as properties of the new table. Composition deals more with physical entities than aggregation. Composition examples are usually found in factories.
We saw an example of an aggregation relationship in the previous part of the series. There we had a Sale table and a SaleItem table. In this tutorial we shall look at an example of a composition relationship.
Example
Consider a factory where bicycles are manufactured. The ultimate object (class) is a bicycle. This bicycle is built from wheels, crank, stem, etc. This means that the classes of wheels, crank, stem, etc. ultimately form the bicycle class. In other words the bicycle object is built from the objects, wheels, crank, stem, etc. Fig 8.1 shows a class diagram for this bicycle composition relationship. You have to open the following link in a new browser tab to see the figure.
In the diagram the diamonds are filled diamonds, while for the aggregate relationship, the diamond is an open diamond.
The tables for the components are linked to the Bicycle table by the presence of their IDs in the Bicycle table.
Conclusion
In a composition you have classes that ultimately become a new class. In the above example, the Wheels, Crank and Stem classes, all became the Bicycle class (finished product). This means that you have tables whose rows (properties), can be described as properties of the new table. Composition deals more with physical entities than aggregation. Composition examples are usually found in factories.
Chrys
Related Links
Major in Website DesignWeb Development Course
HTML Course
CSS Course
ECMAScript Course
NEXT