Broad Network


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

This is part 8 of my series, Database Essentials. Database Essentials is division 1 of a set of tutorials I have on Database. In this part of the series, we look at what is called the Composition Association. This is another kind of relationship we have to learn. Our aim is to discover the nature of this association and not to know how to derive it or when to use it or how to use it.

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.

http://www.broad-network.com/ChrysanthusForcha/composition.htm

There are four tables in the diagram. You have the bicycle table where each row is for one bicycle (finished product). You have the Wheels table where each row is for a wheel (component) in the factory store. You have the Crank table where each row is for a crank (component) in the factory store. You have the Stem table where each row is for a stem in the factory store. For each row in the Bicycle table, there are two rows in the Wheels table (one bicycle has two wheels), one row in the Crank table and one row in the Stem table. In practice, there will be many other component tables, not just three as indicated.

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 Design
Web Development Course
HTML Course
CSS Course
ECMAScript Course
NEXT

Comments

Become the Writer's Fan
Send the Writer a Message