In this module, you have worked with structured data in tables.
For example, a soccer roster might contain:
| Player ID | Name | Jersey Number | Position |
|---|---|---|---|
| P001 | Jordan | 7 | Forward |
| P002 | Casey | 1 | Goalkeeper |
A spreadsheet emphasizes records and fields.
A UML class diagram can describe the same information from a software-modeling perspective.
Instead of showing every current row, the class diagram describes the kind of object the software can represent.
If one row represents one player, a useful software class is:
PlayerThe table fields can suggest attributes for that class.
Conceptually:
Player
--------------------------------
playerId : string
name : string
jerseyNumber : int
position : stringThe class diagram does not show Jordan and Casey as current rows.
It describes the structure that Player objects can use.
Consider the table headers:
Player ID
Name
Jersey Number
PositionThose fields can correspond to class attributes:
playerId
name
jerseyNumber
positionThe two representations use different notation, but they can describe closely related information.
Spreadsheet:
column → field across many recordsClass diagram:
attribute → information available on objects of that classA structured-data table may contain values such as:
P001
Jordan
7
ForwardA UML class diagram can make the expected types explicit:
Player
--------------------------------
playerId : string
name : string
jerseyNumber : int
position : stringThe class diagram says more than “this information exists.”
It tells a software designer what kind of value each attribute is expected to contain.
Suppose a soccer workbook separates teams and players.
| Team ID | Team Name |
|---|---|
| T001 | Wildcats |
| Player ID | Name | Team ID |
|---|---|---|
| P001 | Jordan | T001 |
| P002 | Casey | T001 |
The structured data uses the value:
T001to connect player records to the team record.
A UML class model can represent two related software types:
Player -------- TeamConceptually:
Player
--------------------------------
playerId : string
name : string
jerseyNumber : int
Team
--------------------------------
teamId : string
name : stringThe relationship communicates that Player and Team objects are connected in the software model.
A spreadsheet or ERD may require identifiers because records need stable identities.
A software class diagram may also contain an identifier when the software needs it.
But the diagrams do not have to contain identical attribute lists simply because they describe the same domain.
Ask what each model is for.
If the application needs to retain a playerId, the class attribute is useful.
If the ID exists only for a data-storage purpose that the software model does not need to expose at this level, the model may differ.
The purpose controls the representation.
Consider:
Player
--------------------------------
playerId : string
name : string
jerseyNumber : intThis can be read as:
Compare that with one spreadsheet row:
P001 | Jordan | 7The row says:
That is the difference between describing a type and displaying a record.
A table may contain fifty player rows.
The UML class diagram does not need fifty Player boxes.
One:
Playerclass can describe the common structure for many Player objects.
That is similar to how one table header defines the field structure for many records.
Suppose you model:
Player -------- TeamThe line should correspond to an actual relationship in the system.
Do not connect classes merely because their tables happen to appear in the same workbook.
For the soccer example, a meaningful statement is:
That gives the relationship a purpose.
Both representations can show:
Their emphasis differs.
An ERD is primarily a data-oriented model.
A UML class diagram is primarily a software-oriented model.
The next Learning Activity compares those two views directly.