UML quick course
https://chatgpt.com/share/67adaa1c-a78c-8010-87d8-692202530e42
| UML Relationship | Arrow Type | Example |
|---|---|---|
| Association | —→ (or ——) |
Person → Car |
| Aggregation | ◇— (hollow diamond) |
Team ◇— Player (Players exist independently) |
| Composition | ◆— (filled diamond) |
House ◆— Room (Rooms cannot exist without a House) |
| Inheritance (Generalization) | —▷ (hollow triangle) |
Dog ▷ Animal (Dog is-a Animal) |
| Dependency | —⥤ (dashed line with open arrow) |
Car - - ⥤ Fuel (Car depends on Fuel) |
| Realization (Implements an Interface) | - - - ▷ (dashed line with a hollow triangle) |
Car - - - ▷ Vehicle (Vehicle is an interface, and Car implements it) |

Association in UML
Definition:
Association represents a structural relationship between two or more classes that shows how objects of these classes are related to each other. It defines how instances of one class connect to instances of another.
Types of Association
-
One-to-One (1:1)
-
Each instance of Class A is associated with exactly one instance of Class B.
-
Example: Person has one Passport.
-
UML Representation:
Person -------- Passport (1) (1)
-
-
One-to-Many (1:M)
-
One instance of Class A is associated with multiple instances of Class B.
-
Example: Teacher teaches multiple Students.
-
UML Representation:
Teacher -------- Student (1) (0..*)
-
-
Many-to-Many (M:N)
-
Many instances of Class A are associated with many instances of Class B.
-
Example: Students enroll in multiple Courses, and each Course has multiple Students.
-
UML Representation:
Student -------- Course (0..*) (0..*)
-
Association vs. Aggregation vs. Composition
| Concept | Definition | Arrow Type | Example |
|---|---|---|---|
| Association | Objects are related but exist independently. | —→ (or ——) |
Person → Car (Person owns a Car) |
| Aggregation | A whole-part relationship where parts can exist independently. | ◇— (hollow diamond) |
Team ◇— Player (Players exist independently of the Team) |
| Composition | A whole-part relationship where parts cannot exist independently. | ◆— (filled diamond) |
House ◆— Room (Rooms cannot exist without a House) |