Garfield Student
Garfield Student

Reputation: 65

Class diagram relationship diamonds

When creating relationships in an Object Class Diagram for an Object Relational Database, should the diamonds on the ends of the relationship links be filled in or not.

Here is an image of my Class diagram:

http://canning.co.nz/Weltec/Class_Diagram.png

Upvotes: 0

Views: 409

Answers (3)

TinTin
TinTin

Reputation: 201

Composition relationship has a coloured diamond shape structure ending at a class if it belongs to a 'is a' relationship (i.e- the entity cannot exist without the parent class) whereas the aggregation has an empty diamond shape ending at a class if it belongs to a 'has a' relationship (i.e- the entity can exist without the existence of the parent class.

Upvotes: 1

Jens Schauder
Jens Schauder

Reputation: 81990

A full diamond denotes Composition, or a 'owns' relationship. You use it when the referenced entity can't exist without the class representing it. An example would be order to order item. The order item just doesn't make sense without the order.

An empty diamond denotes Aggregation, or a 'has' relationship. A quick glance at your diagram makes me think this is the correct diagram element to use in your case.

But I agree with @mpartel: If there aren't any specific requirements to distinguish between the two just ignore the diamonds.

Upvotes: 0

mpartel
mpartel

Reputation: 4492

It's a choice between Composition and Aggregation, which Wikipedia explains quite well.

In practice though, I think a valid answer is to just not worry about the difference, unless it's a school assignment. I've found that trying to make very detailed UML diagrams isn't terribly useful in practice.

Upvotes: 1

Related Questions