Chinaunix首页 | 论坛 | 博客
  • 博客访问: 710307
  • 博文数量: 145
  • 博客积分: 3446
  • 博客等级: 中校
  • 技术积分: 1567
  • 用 户 组: 普通用户
  • 注册时间: 2006-08-30 13:58
文章分类

全部博文(145)

文章存档

2021年(1)

2020年(1)

2019年(1)

2018年(6)

2017年(1)

2016年(10)

2015年(12)

2014年(10)

2013年(15)

2012年(33)

2011年(21)

2010年(9)

2009年(18)

2008年(2)

2006年(5)

我的朋友

分类: Web开发

2014-07-28 18:09:34


Association, Aggregation, Composition

When we have only one relationship between objects, that is called Association.

Aggregation and Composition both are specialized form of Association.

Composition is again specialize form of Aggregation.


Association is a relationship where all objects have their own life-cycle and there is no owner. Let's take an example of Teacher and Student. Multiple students can associate with single teacher and single student can associate with multiple teachers but there is no ownership between the objects and both have their own life-cycle. Both can create and delete independently.


Aggregation is a specialize form of Association where all object have their own life-cycle but there is ownership and child object can not belongs to another parent object. Let's take an example of Department and teacher. A single teacher can not belongs to multiple departments, but if we delete the department teacher object will not destroy. We can think about "has-a" relationship.


Composition is again specialize form of Aggregation and we can call this as a "death" relationship. It is a strong type of Aggregation. Child object dose not have their life-cycle and if parent object deletes all child object will also be deleted. Let's take again an example of relationship between House and rooms. House can contain multiple rooms there is no independent life of room and any room can not belongs to two different house if we delete the house room will automatically delete. Let's take another example relationship between Questions and options. Single questions can have multiple options and option can not belong to multiple questions. If we delete questions options will automatically delete.

阅读(1589) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~