UML Class Diagram

UML (Unified Modeling Language) Class Diagrams are used for Conceptual Data Modeling — capturing the domain’s entities, attributes, and relationships at a high level before translating to a logical Entity-Relationship Diagram (ERD). UML is often preferred for conceptual modeling because it is more expressive and cleaner than ERD notation for representing type hierarchies and complex relationships.

Class Structure

A class has three compartments:

┌──────────────────┐
│     ClassName     │  ← Name
├──────────────────┤
│ - attribute1: Type│  ← Attributes
│ - attribute2: Type│
├──────────────────┤
│ + method(): Type  │  ← Operations (optional for DB modeling)
└──────────────────┘

Visibility markers: + public, - private, # protected, ~ package.

Relationship Types

Association

A domain-level connection between classes. Bidirectional by default.

Student ────── Course
        enrolls

Aggregation (◇──)

A whole-part relationship where parts can exist independently of the whole. Hollow diamond on the whole side.

Example: Department ◇── Employee (employees exist without the department)

Composition (◆──)

A stronger whole-part relationship where parts cannot exist independently. Filled diamond.

Example: Order ◆── OrderItem (order items don’t exist without the order)

Generalization (△──)

Class hierarchy / inheritance. Hollow triangle arrowhead.

Example: Person △── Student, Person △── Employee

Multiplicity

Annotations on relationship endpoints defining how many instances participate:

NotationMeaning
1Exactly one
0..1Zero or one (optional)
* or 0..*Zero or more
1..*One or more (at least one)
n..mBetween n and m

Read from one class toward the other: “One instance of Class A is associated with [multiplicity] instances of Class B.”

Aggregation and Composition Patterns

The source material identifies several recurring patterns for recognizing aggregation and composition in a domain. Both are anti-symmetric and transitive (if A contains B and B contains C, then A contains C).

PatternTypeExampleKey Phrase
Assembly-PartsAggregationCar ◇── Engine, Wheel”is assembled from”
Container-ContentAggregationWebPage ◇── AdFrame”holds”, “displays”
Organization-MemberAggregationTeam ◇── Player”consists of members”
Material-ObjectCompositionPaper ◆── WoodFiber, Cotton”is made from”
Portion-IngredientCompositionPie ◆── Slice (homomeric)“portion of”
Place-AreaCompositionCountry ◆── State ◆── City”is located in”
Collection-MembersCompositionWeeklyTimesheet ◆── DailyTimesheetordered, permanent parts

When in doubt, model the relationship as an association — it can always be refined into aggregation or composition when additional constraints are discovered.

Mapping to ERD

UMLERD
ClassEntity
AttributeAttribute
AssociationRelationship with Foreign Key
AggregationRelationship (parts optional)
CompositionRelationship with CASCADE delete
GeneralizationCollapsed via discriminator column, separate tables, or shared PK
Many-to-ManyJunction Table