Introduction to UML Diagrams
What are they, and when do you use each one?
A structural diagram that shows classes, attributes, methods, and relationships. Think of it as a blueprint of the system data.
A behavioral diagram that shows what the system does from the user's perspective. It maps actors to goals.
| Feature | Class Diagram | Use Case Diagram |
|---|---|---|
| Type | Structural | Behavioral |
| Focus | What data exists and how it relates | What users can do with the system |
| Main element | Classes with attributes and methods | Actors and use cases |
| Relationship types | Association, inheritance, composition, aggregation | Association, include, extend, generalization |
| Answers | "What is the system made of?" | "Who does what with the system?" |
Class Diagram - Cheat Sheet
Everything you need to draw a correct class diagram
Top: class name. Middle: attributes. Bottom: methods or operations.
| Relationship | Symbol | Meaning | Example |
|---|---|---|---|
| Association | ────── |
A general connection. | Customer -> Review |
| Aggregation | ◇────── |
Weak has-a ownership. | ParkingArea ◇── ParkingSlot |
| Composition | ◆────── |
Strong has-a ownership. | ParkingSession ◆── Payment |
| Inheritance | ──────▷ |
Is-a relationship. | Member ──▷ Customer |
| Dependency | - - - -→ |
Temporary use. | Payment - - -> PaymentGateway |
| Notation | Meaning | Example |
|---|---|---|
1 |
Exactly one | ParkingSession has exactly 1 Payment |
0..1 |
Zero or one | A slot may or may not have a Reservation |
0..* |
Zero or more | A Customer can have many ParkingSessions |
1..* |
One or more | A ParkingArea has at least one ParkingSlot |
0..3 |
Zero up to 3 | A Member can have 0 to 3 active Reservations |
{ max 3 active reservations per member }.Customer, Member, ParkingArea, ParkingSlot, Reservation, ParkingSession, Payment, Review, Administrator.
Remove Database, WebServer, LoginPage, Button, Screen, and vague System classes.
Use persistent information from the scenario.
Member makes Reservation; Member is a Customer; ParkingSession has Payment.
Put numbers at both ends of every association.
Use curly braces for rules like the maximum three reservations rule.
- Every class has a singular noun name
- Relevant attributes are listed with types
- Visibility symbols are used consistently
- Inheritance arrow points to the parent
- Multiplicity appears at both association ends
- Constraints are shown in curly braces
- No UI, database, or web server classes
Use Case Diagram - Cheat Sheet
Everything you need to draw a correct use case diagram
| Element | Notation | Description |
|---|---|---|
| Actor | Stick figure |
External person or system. |
| Use Case | Oval |
User goal written as a verb phrase. |
| System Boundary | Rectangle |
Use cases inside; actors outside. |
| «include» | Dashed arrow |
Mandatory behavior. |
| «extend» | Dashed arrow |
Optional behavior. |
Always happens.
End Parking Session «include» -> Make Online Payment
Sometimes happens.
Leave Feedback «extend» -> Rate Parking Area
Customer, Member, Administrator, Payment Gateway.
Use verb phrases like View Available Slots and Reserve Slot.
Use cases inside and actors outside.
Use solid association lines.
Include is mandatory. Extend is optional.
- System boundary is drawn and labeled
- Actors are outside the boundary
- Use cases are inside the boundary
- Each use case uses a verb phrase
- Every actor connects to at least one use case
- Include and extend arrows point correctly
Worked Example: Smart Parking System
Full class diagram and use case diagram with explanations
A web-based system manages a smart parking service. The system handles multiple parking areas and parking slots. It records which customers reserve or use parking slots and when.
For each parking session, the start time, end time, and total fee are recorded. The system tracks available and occupied parking slots in real time.
Members can reserve parking slots in advance. A member can reserve up to 3 parking slots at a time. Customers can make online payments, rate parking areas from 1-5, and leave anonymous feedback.
The system stores customer information: name, phone number, car plate number, and email. Members have a membership ID and password. Administrators manage parking areas and slots, including location and pricing details.
Scroll horizontally on mobile. Connector lines are routed around class boxes to avoid overlaps.
| Class | Why included |
|---|---|
| Customer | Customers park, pay, and review. |
| Member | Specialized Customer with reservations and discounts. |
| ParkingArea | Represents managed locations and pricing. |
| ParkingSlot | Represents slots and availability status. |
| Reservation | Records advance bookings. |
| ParkingSession | Records actual use and fee. |
| Payment | Stores payment details. |
| Review | Stores rating, feedback, and anonymity. |
Scroll horizontally on mobile. Actor links use short, direct routes and include/extend arrows follow UML direction rules.
| Actor | Why included |
|---|---|
| Customer | Primary user who parks, pays, and reviews. |
| Member | Specialized customer with reservation privileges. |
| Administrator | Manages infrastructure and pricing. |
| Payment Gateway | External payment processor. |
Before You Submit - Final Checklist
Run through this before handing in any UML assignment
- Every requirement noun is represented by a class or attribute
- No implementation classes
- Attributes use visibility symbols
- Multiplicity is shown at both ends
- Generalization arrow points to the parent class
- Constraints are written in curly braces
- System boundary is drawn and labeled
- Actors are outside the boundary
- Use cases are inside the boundary
- Use cases use verb phrases
- Include and extend arrows point correctly
- Login is not listed as a goal use case