An online shop needs a small set of core types: customers, orders, the lines inside an order, products and payments. This UML class diagram shows those classes, their fields and methods, and how they relate: who owns whom, how many of each, and which classes inherit from a common parent.
It is the model a team agrees on before writing the code and the database tables.
1. The Diagram
Customer 1 to 0..* Order: one customer can place zero or more orders; each order belongs to exactly one customer.
Order to OrderLine (filled diamond): composition. Lines cannot exist without their order; delete the order and its lines go too. Every order has at least one line (1..*).
OrderLine to Product (arrow): a navigable association. A line knows its product, but a product does not keep a list of every line that ever sold it. The line copies unitPrice so later price changes do not rewrite old orders.
Order to Payment 0..*: an order may have no payment yet, or several (for example a gift card plus a card).
Payment hierarchy:Payment is abstract (italic name), and its authorize() is abstract too. Each subclass adds its own fields and implements authorize(); the hollow triangle points to the parent.
OrderStatus is an enumeration; the dashed arrow says Order depends on it.
2. How to Read It
Multiplicities sit at the far end of a line: read Customer places 0..* Order from left to right. The diamond always sits on the whole side of a whole-part relation.
3. Variant: Object Diagram Snapshot
An object diagram uses the same boxes but with underlined name : Type and real values. It is a quick way to test a class diagram: if you cannot draw a believable snapshot with it, the model is wrong. Here the amounts add up, and the snapshot obeys every multiplicity in the class diagram.
4. Pros and Cons
Pros
The most widely understood UML diagram; most developers can read it without training.
Pins down vocabulary: the whole team says OrderLine, not "item" in one place and "row" in another.
Multiplicities expose real business rules (can an order exist without lines?).
Maps directly to classes, ORM entities and database tables.
Tools can generate it from code, or code from it.
Cons
Static only: it says nothing about when things happen.
Gets cluttered past about 15 classes; split it by package or bounded context.
Easy to over-specify getters, setters and private details nobody needs.
Inheritance looks neat on paper but is often worse than composition in code.
5. When to Use It
Use it when
Designing a new domain model or database schema.
Onboarding developers to an existing codebase.
Reviewing a change that adds or splits a core entity.