0.6.19 ERDs vs. Class Diagrams: Two Views of Structure

Two Views of Structure: Records and Software Objects

Both an ERD and a UML class diagram can show teams and players. Their similar nouns can hide different modeling questions. The ERD below organizes stored records. The class diagram organizes the software objects that use those records.

ERD: Identify Records and Relate Their Keys
Player rows have primary keys and a TeamId foreign key to one Team; Team can have zero or many player rows.
A foreign key relates player records to team records
  • New
  • Changed
  • Removed

The relationship is implemented in these records by matching TeamId values. The ERD can explain the one-team-per-player data rule and which key must exist; it does not show a live object reference or a sequence of method calls.

Class View: Types and Their Reference Relationship
Player has a Name attribute and a required Team reference to one Team object, which also has a Name attribute.
A software reference can connect the related objects
  • New
  • Changed
  • Removed

The software can resolve TeamId during loading and store a reference to the resulting Team object. A class model may also keep the IDs when persistence needs them. The relationship concept is related, but the storage representation is a deliberate choice.

Use the View That Fits the Work
  1. Use an ERD to check record identifiers, foreign keys, and relationship cardinalities.
  2. Use a class diagram to check software types, typed members, and relationships.
  3. Use example records or object snapshots to test the design with concrete values.