Class vs ER diagram: domain modeling
Introduction
Class diagrams and ER diagrams both describe structured data, but with different focuses: class diagrams target object-oriented design with classes, attributes, and methods; ER diagrams target database design with entities, attributes, and relationships. This post uses the same business scenario to demonstrate both PlantUML and Mermaid syntax, then compares them side by side.
PlantUML
1 | @startuml |
PlantUML uses the class keyword to define class blocks, - for private members, + for public, and (): ReturnType for methods. Relationships use A --> B with multiplicity labels.
Mermaid
1 | classDiagram |
Mermaid’s classDiagram uses class with braces for member definitions. Access modifiers use - and + the same way. Relationships use --> with multiplicity; in HTML rendering --> must be escaped as -->.
Side by side
| Feature | PlantUML | Mermaid |
|---|---|---|
| Relationship arrow | A --> B |
A --> B |
| Multiplicity position | After arrow "1" --> "*" |
After arrow "1" -- *" |
| Method return type | +method(): Type |
+method(): Type |
| Private member | -field |
-field |
| Relationship label | : label |
: label |
Wrap-up
Class diagrams suit object-oriented analysis and design, while ER diagrams are better for database schema design. PlantUML has a richer ecosystem for complex projects (skinparam, themes), and Mermaid embeds more easily in Markdown docs and web pages. Knowing both gives you flexibility when communicating designs.
- Title: Class vs ER diagram: domain modeling
- Author: puml.online
- Created at : 2026-10-14 01:00:33
- Updated at : 2026-12-06 10:29:22
- Link: https://puml.online/en/blog/class-vs-er-for-domain/
- License: This work is licensed under CC BY-NC-SA 4.0.