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
name = “Sue”
Alice: Person
name = “Alice”
GE: Company
name = “GE”
IBM: Company
name = “IBM”
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
name
OwnsStock
* *
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
name
CapitalCity
name
HasCapital
1 1
India: Country
name = “India”
Delhi: CapitalCity
name = “Delhi”
HasCapital
One - to – one association
A BanAssociation
* *anA:A aB:B
aLink
A BanAssociation* *
anA:A aB:B
aLink
anotherAssociation* *
anotherLink
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
Each directory has exactly one user who is an owner and many users who are authorized to use the directory.
User Directory
*
1owner
authorizedUser *
* 0..1
*
container
contains
Use association end names to model multiple references to the same class
one person instance participates in two or more links, twice as a parent and zero or more times as a child.
Person
0..2
*
parent
child
Ordering
• 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
Screen WindowVisibleOn1 *
{ordered}
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 User
accessPermission
/etc/temp read Ram/etc/temp read-write Mohan/usr/lgn read-write Shyam
AccessibleBy
* *
Personnamedobaddress
Nameaddress
SalaryJob-title
performanceRating
boss
Manages
workerWorksFor
Company
0..1
*
* 0..1
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 one-to-many and many-to-many associations.
• A qualifier selects among the target objects, reducing the effective multiplicity from “many” to “one”.