Vous êtes sur la page 1sur 21

Link and Association

Concepts

A link is a physical or conceptual


connection among objects
Most links relate two objects, but
some links relate three or more
objects

John: Person
name = John

Mary: Person
name = Mary

Sue: Person

GE: Company
name = GE

IBM: Company
name = IBM

name = Sue

Alice: Person
name = Alice

Object diagram

John and Mary own stock in GE


company. Mary and Sue own
stock in IBM company. Alice does
not own stock in any company
and thus has no link

An association is a description of a
group of links with common structure
and common semantics.
The links of an association connect
objects from the same classes.
An association describes a set of
potential links in the same way that a
class describes a set of potential
objects

Person
name

Company

OwnsStock
*

* name

Class diagram

A person may own stock in zero or more


companies; a company may have multiple
persons owing its stock

The UML notation for a link is a line


between objects.
If a line has a name, it is underlined.
An association connects related
classes and is also denoted by a line
When there are multiple
associations, you must use
association names or association end
names to resolve the ambiguity.

Multiplicity
Multiplicity specifies the number of
instances of one class that may relate to
a single instance of an associated class.
It is a subset of nonnegative integers.
UML diagrams explicitly list multiplicity
at the end of association lines.
UML specifies multiplicity with an
interval, such as 1 (exactly one),
1..* (one or more), or 3..5 (three to
five inclusive) or * (many/ zero or
more)

Country

HasCapital
1

name

India: Country
name = India

CapitalCity
1 name

HasCapital

Delhi:
CapitalCity
name = Delhi

One - to one association

Workstation

console
1

0..1

Zero - or one
multiplicity

Window

anAssociation
*

anA:
A

aLink

anA:
A

anAssociation

anotherAssociation

aLink
anotherLink

aB:B

aB:B

Association End Names

Person

employee
*

employer
WorksFor

0..
1

Company

Association end names are necessary


for associations between two objects
of the same class. They can also
distinguish multiple associations
between a pair of classes
owner 1

Directory

User
authorizedUser *

container0..1

contains *

Each directory has exactly one user


who is an owner and many users who
are authorized to use the directory.

Use association end names to model


multiple references to the same class
parent 0..2
Person
child *

one person instance participates in


two or more links, twice as a parent
and zero or more times as a child.

Ordering
Screen

{ordered}
1

VisibleOn

Window

Workstation screen contains a number of


overlapping window
Each window on a screen occurs at most once.
The window have an explicit order, so only the
top most window is visible at any point on the
screen

Bags and Sequences


A bag is a collection of elements with
duplicates allowed
A sequence ordered collection of
elements with duplicates allowed
Ordered disallows duplicates

Association Classes
An association class is an association
that is also a class
It can have attributes and operations
and participate in associations

File

AccessibleBy
accessPermission

/etc/temp
Ram
/etc/temp
Mohan
/usr/lgn
Shyam

read
read-write
read-write

User

boss
0..1

Person

name
dob
address

worker

Manages

0..1

Company
Name
address

WorksFor
Salary
Job-title

performanceRating

Each person working for a company


receives a salary and has a job title.
The boss evaluates the performance of
each worker

Qualified associations
A qualified association is an association in
which an attribute called the qualifier
disambiguates the objects for a many
association end.
It is possible to define qualifiers for oneto-many and many-to-many associations.
A qualifier selects among the target
objects, reducing the effective multiplicity
from many to one.

Bank

Account
accountNumber

Not Qualified

Bank

accountNum
ber

Qualified

0..1

Account

StockExchange

Lists

Company

tickerSymbol

Not Qualified

StockExchange tickerSymbol

Qualified

Lists

0..1

Company

Vous aimerez peut-être aussi