Lesson 10 | Basic object modeling: constraints |

Objective | Constraints as they apply to basic object modeling. |

Any rules that cannot be expressed in the name or in the multiplicity may be added as a constraint.
Place the rule description within curly brackets {} at the end of the association controlled by the rule.

In the previous example, we chose "a point in time" as our time frame. For this example, let's change the time frame to include history.

Now ask "How many customers can hold the same seat over the life of the system?"

In this case, the answer would be "only one at the same time, but many over a period of time."

This multiplicity would be represented as

**0..*: zero to many customers may hold the same seat over time.**

Now ask "How many customers can hold the same seat over the life of the system?"

In this case, the answer would be "only one at the same time, but many over a period of time."

This multiplicity would be represented as

However, the multiplicity alone will not tell you that only one person may hold the seat at the same time.
This added rule requires the use of a constraint.

Two approaches are equally valid:

- Use a multiplicity of 0..* and
- { only one at a time.

In the last diagram, multiplicity by outlining the following characteristics:

- Use a multiplicity of 0..1 to show one at a time and
- a constraint of {historical} to show that you keep history.

Click the Exercise link below to draw class diagrams based on excerpts from the course project problem statement.

**Object Modeling Constraints - Exercise**