Classes, members, and relationships
A class diagram lists classes with their attributes and methods, then draws relationships such as inheritance and association. Use it when the reader needs the object model, not the database tables.
An ER diagram is the neighbor for tables, keys, and cardinality. If the prompt talks about primary keys and join tables, switch to the ER page. Stay here for types, operations, and inheritance.
Class diagram or ER diagram
Choose a class diagram when code structure is the subject. Choose an ER diagram when persistence is the subject. A requirement diagram is a third neighbor when you need links from needs to tests, not from classes to classes.
What to repair in the draft
1. Keep attributes and methods apart
Check that fields sit with attributes and operations sit with methods. Move a misplaced member in the editor.
2. Name the relationship
Inheritance, association, and aggregation are different. If the draft used a plain line for a subclass, change it to inheritance.
3. Remove tables and keys
Primary keys and foreign keys belong on an ER diagram. Delete them here unless the class truly stores that field.
How to phrase the prompt
For each class, give the name, a few attributes with types, and the methods that matter. Then state relationships in sentences, such as Order inherits from Document, or Customer places an Order. Skip SQL.
After the first class draft
- How many classes should one diagram hold?
- One aggregate is enough, such as order, line, and payment. A diagram of the whole system becomes unreadably dense.
- The draft added getters for every field. Should I keep them?
- Remove them unless a getter has real behavior. Keep methods that change state or enforce a rule.
- Can I show a sequence of calls here?
- No. Call order belongs on a sequence diagram or in ZenUML. Keep this diagram to structure.