UML class diagram template
Seven classes, an interface and every relationship kind you are likely to need, laid out so renaming the boxes gives you your own domain model.
Notation: UML 2.5.1Diagram: Class diagram
Open this template in Archyno
It opens as an editable model, not an image. Change it in the browser, then export to PNG, SVG, Mermaid, XMI, or a Sparx .qea file.
Open this templateWhat is on this diagram
- Customer
- The party the model exists to serve. Rename to your own actor.
- Order
- The thing that party creates. Usually the class everything else hangs off.
- OrderLine
- The line items. Composed of the order, so they die with it.
- Product
- The catalogue an order line points at, and outlives it.
- PaymentMethod
- An interface: the point where behaviour varies by subtype.
- Card / Invoice
- Two realizations. Add a third rather than a boolean flag.
How to make it yours
- Rename Customer and Order to the two nouns your domain actually argues about.
- Fix the multiplicities before the attributes - 1 to 0..* is a decision, a String is not.
- Delete any attribute you cannot name a source for. Half of a first draft is invented.
- Keep composition for parts that cannot outlive their whole, and use association everywhere else.
- Add operations last, and only where behaviour belongs to the class rather than to a service.
Common questions
What should a class diagram template include?
Enough structure to be worth editing and no more: a handful of classes with real attributes, at least one interface with two realizations, and the multiplicities filled in. Everything beyond that is a guess about your domain and is faster to add than to remove.
When do I use composition instead of association?
Use composition, the filled diamond, when the part cannot exist without the whole and is deleted with it - an order line without its order is meaningless. Everything else is an association, including the cases where deletion happens to cascade in the database.
Can I export this class diagram template to another tool?
Yes. Opening the template in Archyno gives you a real model rather than a picture, so it exports to a Sparx .qea file, to XMI 2.5.1, and to Mermaid for a repository, as well as to PNG for a document.
Read the notation
Class diagrams
How to read and draw a UML class diagram: the three compartments, visibility markers, multiplicity, and the difference between association, aggregation, composition, generalization and realization.
What is UML?
The Unified Modeling Language in practice: the fourteen diagram types, how structure and behaviour split, and how to pick the right diagram for the question you are actually asking.
ER diagrams
How to read and draw an entity-relationship diagram: entities, attributes, primary and foreign keys, relationships and cardinality in crow's foot notation, the conceptual-logical-physical progression, and how an ER model differs from a UML class diagram.