Introduction and Example of Diagrams (For Reference)
Introduction and Example of Diagrams (For Reference)
Introduction and Example of Diagrams (For Reference)
Prachi Shah
IT Dept.
BVM
Use Case Diagram
“A use case specifies the behavior of a system or a part of a
system, and is a description of a set of sequences of actions,
including variants, that a system performs to yield an observable
result of value to an actor.”
Student
Use Case Diagram (Cont’d)
Actors can participate in a generalization relation with other
actors.
Student Person
Use Case Diagram (Cont’d)
Student
Use Case Diagram (Cont’d)
Here we have a Student interacting with the Registrar and the
Billing System via a “Register for Courses” use case.
Billing System
Registrar
Use Case
Diagram
(Online
shopping)
Data Flow Diagram
DFD: A diagram about the data flow between
external agents (sources/ sinks) and the processes
and data stores within a system
Key Components:
External
Agent
General Information System
In general, a system could be viewed as a
single Process
0
Trans
Report
Source Data Information Sink
(Customer) System (Mgmt)
Data- Compute-
items RMS
0
User
result
Context Diagram
Example: RMS Calculating Software
numbers
Read- Validate-
numbers numbers
1.0 2.0
Valid -
Data- numbers
items error
Compute-
Display rms
4.0 3.0
User
result RMS
Level 1 DFD
Example: RMS Calculating Software
Squared-
Calculate- sum Calculate-
squared-sum mean
3.1 3.2
Valid -
numbers Mean-
Calculate- square
root
User 3.3
RMS
Level 2 DFD
Example: RMS Calculating Software
a b c
sq(a) sq (b)
sq (c)
Sum
3.1.4
Squared-sum
Level 3 DFD
E-R Diagram: Basic Concepts
• Entity set – an abstraction of similar things,
e.g. cars, students
– An entity set contains many entities
• Attributes: common properties of the entities
in a entity sets
• Relationship – specify the relations among
entities from two or more entity sets
An Example
Relationship
• The degree of a relationship = the number of
entity sets that participate in the relationship
• Mostly binary relationships
• Sometimes more
• Mapping cardinality of a relationship
• 1 –1
• 1 – many
• many – 1
• Many-many
1- many
Many - 1
Many - many
Alternative Cardinality Specification
Total Participation
• When we require all entities to participate in the
relationship (total participation), we use double lines to
specify
• Every loan has to have at least one customer
Self Relationship
• Sometimes entities in a entity set may relate to
other entities in the same set. Thus self relationship
• Here employees mange some other employees
• The labels “manger” and “worker” are called roles
of the self relationship
More examples on self-relationship
• People to people
– Parent – children
– Manager – employee
– Husband – wife
• Word to word
– Root – synonym
Attributes
• Both entity sets and relationships can have
attributes
• Attributes may be
– Composite
– Multi-valued (double ellipse)
– Derive (dashed ellipse)
Another Example
Ternary Relationship
Converting Ternary to binary
Weak Entity Set
• Some entity sets in real world naturally
depend on some other entity set
– They can be uniquely identified only if
combined with another entity set
• Example:
– section1, section2, … become unique only if
you put them into a context, e.g. csce4350
Weak Entity Set Notations
Double rectangles for weak entity set
Double diamond for weak entity relationship
Dashed underscore for discriminator
Specialization
• A lower-level entity set inherits all the attributes
and relationship participation of the higher-level
entity set to which it is linked.
• A lower-level entity set may have additional
attributes and participate in additional relationships
Specification
• Disjoint
• Completeness constraint (use double lines)
– total : an entity must belong to one of the lower-
level entity sets
– partial: an entity need not belong to one of the
lower-level entity sets
Notations
Notations
ER Practice
• Design an ER diagram for an online music
store. The database will contain at least the
following concepts: songs, artists, bands,
albums, and genres.
Class Diagram
A class is a description of a set of
ClassName objects that share the same attributes,
operations, relationships, and semantics.
attributes
Graphically, a class is rendered as a
rectangle, usually including its name,
operations attributes, and operations in separate,
designated compartments.
Class Names
The name of the class is the only required
ClassName tag in the graphical representation of a
class. It always appears in the top-most
attributes compartment.
operations
Class Attributes
Person
/ age : Date
Class Attributes (Cont’d)
Person
Attributes can be:
+ name : String
+ public
# address : Address
# protected
# birthdate : Date
- private
/ age : Date
/ derived
- ssn : Id
Class Operations
Person
name : String
address : Address
birthdate : Date
ssn : Id
eat Operations describe the class behavior
sleep and appear in the third compartment.
work
play
Class Operations (Cont’d)
PhoneBook
SmokeAlarm
Responsibilities
• dependencies
• generalizations
• associations
Dependency Relationships
A dependency indicates a semantic relationship between two or
more elements. The dependency from CourseSchedule to
Course exists because Course is used in both the add and
remove operations of CourseSchedule.
CourseSchedule
Course
add(c : Course)
remove(c : Course)
Generalization Relationships
Person
A generalization connects a subclass
to its superclass. It denotes an
inheritance of attributes and behavior
from the superclass to the subclass and
indicates a specialization in the subclass
of the more general superclass.
Student
Generalization Relationships (Cont’d)
UML permits a class to inherit from multiple superclasses,
although some programming languages (e.g., Java) do not permit
multiple inheritance.
Student Employee
TeachingAssistant
Association Relationships
If two classes in a model need to communicate with each other,
there must be link between them.
Student Instructor
Association Relationships (Cont’d)
We can indicate the multiplicity of an association by adding
multiplicity adornments to the line denoting the association.
Student Instructor
1..*
Association Relationships (Cont’d)
Student Instructor
1..*
Association Relationships (Cont’d)
We can also indicate the behavior of an object in an association
(i.e., the role of an object) using rolenames.
membership
Student Team
1..* 1..*
Association Relationships (Cont’d)
We can specify dual associations.
member of
1..* 1..*
Student Team
1 president of 1..*
Association Relationships (Cont’d)
We can constrain the association relationship by defining the
navigability of the association. Here, a Router object requests
services from a DNS object by sending messages to (invoking
the operations of) the server. The direction of the association
indicates that the server has no knowledge of the Router.
Router DomainNameServer
Association Relationships (Cont’d)
Associations can also be objects themselves, called link classes
or an association classes.
Registration
modelNumber
serialNumber
warrentyCode
Product Warranty
Association Relationships (Cont’d)
A class can have a self association.
next
LinkedListNode
previous
Association Relationships (Cont’d)
We can model objects that contain other objects by way of
special associations called aggregations and compositions.
Engine
Car
Transmission
Association Relationships (Cont’d)
A composition indicates a strong ownership and coincident
lifetime of parts by the whole (i.e., they live and die as a
whole). Compositions are denoted by a filled-diamond
adornment on the association.
Scrollbar
1 1
Window Titlebar
1 1
Menu
1 1 .. *
Another example
Whole Class
Class W Association
Models the part–whole relationship
Composition
Class P1 Class P2 Also models the part–whole relationship but, in
addition, Every part may belong to only one
whole, and If the whole is deleted, so are the
Part Classes parts
[From Dr.David A. Workman]
Example Example:
A number of different chess boards: Each square
belongs to only one board. If a chess board is
thrown away, all 64 squares on that board go as
well.
Figure 16.7
Interfaces
VendingMachine
Interfaces
inputStream
FileWriter
{file must not be locked}
Compiler
FrontEnd BackEnd
Packages (Cont’d)
Classes in the BackEnd package now have access to the classes
in the FrontEnd package.
Compiler
FrontEnd BackEnd
Packages (Cont’d)
JavaCompiler Java
Cardinality in Class diagram
Class diagram for
Banking system
Class diagram for
Shopping system
Activity Diagram
• An activity diagram is essentially a flowchart, showing
the flow of control from activity to activity.
• Use activity diagrams to specify, construct, and
document the dynamics of a society of objects, or to
model the flow of control of an operation.
• Whereas interaction diagrams emphasize the flow of
control from object to object, activity diagrams
emphasize the flow of control from activity to activity.
• An activity is an ongoing non-atomic execution within
a state machine.
Activity Diagram – example 1
Receive
Order
Multiple Trigger
Check
Cancel Authorize
Line
Order [failed]
Payment
Item
Assign to
Order
Synchronization Condition
[need to
reorder] Reorder
Item
[stock assigned to
all line items and
payment authorized]
Dispatch
Order
Activity diagram
(Online shopping)
Activity diagram for
State Diagram
• “The state diagram describes the dynamic behavior of objects
over time by modeling the lifecycles of objects of each class.
• Each object is treated as an isolated entity that communicates with
the rest of the world by detecting events and responding to them.
• Events represent the kinds of changes that objects can detect...
Anything that can affect an object can be characterized as an
event.”
• An object must be in some specific state at any given time during
its lifecycle.
• An object transitions from one state to another as the result of
some event that affects it.
• There can be only one start state in a state diagram, but there may
be many intermediate and final states.
State Diagram symbols
start state final state
simple state
selecting
verifying
select another course
check schedule
sign schedule
checking schedule
scheduled
State diagram (Online shopping)
Activity Diagram
State Diagram
Sequence Diagram
A sequence diagram is an interaction diagram that emphasizes
the time ordering of messages. It shows a set of objects and the
messages sent and received by those objects.
check()
[check = “true”]
Notice that the bottom arrow is different.
remove() The arrow head is not solid, and there is
no accompanying message.
* prepare()
An iteration marker, such as * (as
shown), or *[i = 1..n] , indicates
that a message will be repeated as
Iteration indicated.
marker
Sequence Diagram Example 1
an Order Entry
an Order an Order Line a Stock Item
window
prepare()
Condition
* prepare()
Object
check()
Creation
Sequence
diagram
(Online
shopping)
Swim-lane
diagram
Collaboration Diagram
A collaboration diagram emphasizes the relationship of the
objects that participate in an interaction. Unlike a sequence
diagram, you don’t have to show the lifeline of an object
explicitly in a collaboration diagram. The sequence of events are
indicated by sequence numbers preceding messages.
Object identifiers are of the form objectName : className, and
either the objectName or the className can be omitted, and the
placement of the colon indicates either an objectName: , or a
:className.
Collaboration vs Sequence
Diagram
1: prepare() Message
: Order Self-Delegation
5: needToReorder()
Examples:
Another example
Requirements Model (Analysis Model)
Use-case Sequence
CRC models
diagrams diagrams
Activity Collaboration
diagrams diagrams
Swim lane
diagram