---
title: "Domain modeling; attributes and associations guidelines"
subject: "Object Oriented Analysis and Design"
chapter: 2
key: "semester_6/object_oriented_analysis_and_design:domain-modeling-attributes-associations"
source: https://www.bctengineer.com/q/semester_6/object_oriented_analysis_and_design/domain-modeling-attributes-associations
site: BCT Engineering
---

# Domain modeling; attributes and associations guidelines

Object Oriented Analysis and Design · Chapter 2: Object Oriented Analysis

- Asked in: 2072 Asoj, 6 marks
- Video: [Domain Modeling Crash Course](https://www.youtube.com/watch?v=bduWjKNrnAg) — Tobias Olsson
- Page: https://www.bctengineer.com/q/semester_6/object_oriented_analysis_and_design/domain-modeling-attributes-associations
- Whole chapter: https://www.bctengineer.com/md/semester_6/object_oriented_analysis_and_design/chapter-2

## Question

What do you mean by Domain Modeling? Present the guidelines to add attributes and associations in the domain model.

## Short answer

Domain model is a visual representation of conceptual classes, attributes, and associations of the problem domain (no operations). Attributes: use simple data types, no foreign keys, model quantity with units, avoid derived values unless marked /. Associations: add only needed relationships, name association, show multiplicity, avoid redundant ones.

## Answer

#### Domain modeling
A **domain model** (conceptual class model) is a visual representation of the **conceptual classes** or real-situation objects of the problem domain: the important concepts, their attributes and their relationships. It is the main artifact of OOA. It is drawn as a UML class diagram **without operations**, and it is a "visual dictionary" of the domain's vocabulary. It describes the real world, not software classes.

```text
 +--------+ 1   * +--------+ 1   1..* +---------+
 | Member |-------| Loan   |----------| Book    |
 +--------+ makes +--------+  of      +---------+
 | name   |       | date   |          | title   |
 +--------+       +--------+          | isbn    |
                                       +---------+
```

#### Guidelines to add attributes
1. Include attributes that the requirements suggest or imply a need to remember information (e.g. receipt needs date and time).
2. Use **simple data types** (number, text, date, boolean) for attributes. Relate to other classes with **associations**, not attributes. (Do not make `customerId` in `Sale`; relate `Sale` to `Customer`.)
3. Do not use attributes as **foreign keys**.
4. Model quantities with their units, using a class (`Quantity`, `Money`) when needed.
5. Keep data-type classes (address, phone) as attributes if they are simple; make them classes if they have structure or rules.
6. Do not add attributes whose value can be calculated (derived), unless marked `/`.
7. Keep the model small: add only attributes that matter for the current iteration.

#### Guidelines to add associations
1. Add associations for relationships the system needs to **remember** for some time (need-to-know).
2. Add associations from the **Common Association List**: A is a physical/logical part of B; A is a description of B; A is contained in B; A uses or manages B; A is owned by B; A is a member of B; A is transaction related to B (Customer-Payment); A is next to B; A is a transaction/event recorded in B.
3. Name an association as `ClassName-VerbPhrase-ClassName`, readable in one direction.
4. Show **multiplicity** at both ends.
5. Avoid too many associations, and omit those that can be derived from others (redundant).
6. Use role names where the same class takes part in different ways.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What is a domain model?
   A. A diagram of software classes with all operations
   B. A database schema
   C. A visual representation of conceptual classes of the real problem domain, without operations
   D. A deployment diagram
   Answer: C. It is a UML class diagram without operations showing real-world concepts, attributes and relationships. (Key point: Domain model definition)

2. Which attribute guideline is correct?
   A. Use customerId in Sale as a foreign key
   B. Relate classes with associations, not foreign-key attributes
   C. Always add derived attributes
   D. Add every possible attribute
   Answer: B. Sale should be associated with Customer rather than storing a customerId attribute. (Key point: No foreign keys)

3. How should an association be named?
   A. Any random word
   B. No name is ever needed
   C. With a noun only
   D. ClassName-VerbPhrase-ClassName, readable in one direction
   Answer: D. A verb-phrase name such as Member makes Loan reads naturally in one direction. (Key point: Association naming)

4. Which associations should be added?
   A. Those the system needs to remember for some time (need-to-know) or from the common association list
   B. All possible associations
   C. Only derived or redundant ones
   D. None, only attributes
   Answer: A. Add need-to-know associations and avoid too many or redundant ones. (Key point: Which associations to include)

## Related in Object Oriented Analysis and Design

- [Identify conceptual classes; create domain model](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Aconceptual-classes-domain-model-steps) — Object Oriented Analysis and Design, chapter 2
- [Behavior modeling and four diagrams](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Abehavior-modeling-four-diagrams) — Object Oriented Analysis and Design, chapter 2
- [Forking, joining and branching in modeling](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Aforking-joining-branching-activity) — Object Oriented Analysis and Design, chapter 2
- [Constraint specifications in bank account model](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Aconstraint-specification-bank-account-model) — Object Oriented Analysis and Design, chapter 2
- [Conceptual, specification, implementation model classification](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Ahospital-conceptual-specification-implementation) — Object Oriented Analysis and Design, chapter 2

## Related in other subjects

- [High speed circuit design guidelines](https://www.bctengineer.com/question.md?key=semester_5%2Finstrumentation_ii%3Ahigh-speed-guidelines) — Instrumentation II, chapter 7, asked 3×
- [Add objects of two different classes](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Afriend-add-two-class-objects) — Object Oriented Programming, chapter 4, asked 2×
- [Challenges of modeling a physical system](https://www.bctengineer.com/question.md?key=semester_6%2Fembedded_system%3Amodeling-physical-system-challenges) — Embedded System, chapter 7
- [OLAP vs OLTP; schema modeling; star DMQL](https://www.bctengineer.com/question.md?key=semester_7%2Fdata_mining%3Aolap-oltp-schema-star-dmql) — Data Mining, chapter 2
