ERD vs UML Class Diagram — Key Differences
Compare Entity-Relationship Diagrams with UML Class Diagrams. Understand when to use each, notation differences, and how they map to database vs application design.
Detailed Explanation
Two Diagrams, Two Perspectives
Both ERDs and UML Class Diagrams model structured data with relationships, but they come from different worlds and serve different purposes.
Entity-Relationship Diagram (ERD)
- Focus: Database structure (tables, columns, keys)
- Origin: Database design (Peter Chen, 1976)
- Notation: Crow's foot, Chen, or Bachman notation
- Elements: Entities (tables), attributes (columns), relationships (foreign keys)
- Audience: DBAs, backend developers, data architects
UML Class Diagram
- Focus: Object-oriented software structure (classes, methods, properties)
- Origin: Software engineering (Grady Booch, James Rumbaugh, Ivar Jacobson, 1990s)
- Notation: UML standard notation
- Elements: Classes, attributes, methods, associations, inheritance
- Audience: Software developers, architects, system designers
Side-by-Side Comparison
| Feature | ERD | UML Class Diagram |
|---|---|---|
| Entity / Class | Table with columns | Class with properties and methods |
| Relationships | Foreign keys, junction tables | Association, aggregation, composition |
| Cardinality notation | Crow's foot (──<) |
Multiplicity numbers (1..*) |
| Inheritance | Not native (some use supertype/subtype) | First-class concept (extends) |
| Methods/behavior | Not included | Methods with parameters and return types |
| Data types | SQL types (VARCHAR, INT) |
Language types (String, int) |
| Constraints | PK, FK, UNIQUE, NOT NULL, CHECK | Visibility (+, -, #), stereotypes |
When to Use Each
Use an ERD when:
- Designing or documenting a relational database schema
- Communicating with DBAs or data teams
- Planning migrations between databases
- Generating SQL DDL statements
Use a UML Class Diagram when:
- Designing object-oriented application architecture
- Modeling domain objects with behavior (methods)
- Planning inheritance hierarchies
- Documenting API contracts
Can They Overlap?
Yes. Many ORM tools (like Prisma, TypeORM, or Hibernate) bridge both worlds — your class definitions map to database tables. When using an ORM, an ERD shows the physical database structure while the class diagram shows the application-level object model. The two should be consistent but are not identical.
Use Case
You are deciding which diagram type to use for a design review or documentation effort. Understanding the distinction helps you choose the right tool: an ERD for database-focused discussions and a UML class diagram for application architecture discussions.