Types of relationships : Association vs Composite vs Aggregation

1) Composition 2) Aggregation 3) Association

Association : This is a relationship, where A refers B(B is a part of A), even B can refer A(A is a part of B). But A is niegher parent/child of B. So B can be property/Member input to a function in A.

UniDirectional : when A refers B, but not B refers A.

BiDirectional  : when A refers B, also B refers A.

Additional Info : In an e-commerce application, a customer class has a single association with an account class. The association shows that a customer instance owns one or more instances of the account class. If you have an account, you can locate the customer that owns the account. Given a particular customer, you can navigate to each of the customer’s accounts. The association between the customer class and the account class is important because it shows the structure between the two classifiers.

Composite/Aggregation : This is a relationship, where A refers B(B is a part of A), But B cannot refer A, that is a parent child relationship exists tightly betweeen A & B.

Example to understand Composition & Aggregation :

1) Lets say we have a college with multiple departments, each department having multiple proffessors. Say i delete a department, no need to delete its children, say here department. because i can move the proffessors to another detpartment. This is aggregation. This is denoted by Unfilled Diagnol symbol. Here A has B, B is a part of A, but B exists even though A is deleted.

2) But when i delete College, we need to delete its children say department & Professors. This is Composition. This is denoted by Filled Diagnol symbol. Here A has B, B is a part of A, but B existence completely depends on existence of A, that is if we delete A, B has to be deleted.

Test yourself : This could further help you to get strong in kinds of relations.

Animal & Dog : Is a relationship

Car & Engine : Has a relationship (Aggregation/Composition), where Car is a parent for Engine.

Table & Chair : Association : Since Table can refer to chair, chair can even refer to Table, but no parent child relationship between them.