More Constraints

Let’s learn about a few more types of constraints.

Referential integrity constraints

A referential integrity constraint requires that the values of a reference property refer to an object that exists in the population of the property’s range class. Since we don’t deal with reference properties in this chapter, we’ll postpone the discussion of referential integrity constraints to the chapter on Associations](https://www.educative.io/collection/page/10370001/5397377793392640/5022490478247936).

Frozen and read-only value constraints

A frozen value constraint defined for a property requires that the value of this property must not be changed after it has been assigned. This includes the special case of read-only value constraints on mandatory properties that are initialized at object creation time.

Typical examples of properties with a frozen value constraints are standard identifier attributes and event properties. In the case of events, the semantic principle that the past cannot be changed prohibits changes to the property values of events. In the case of a standard identifier attribute, we may want to prevent users from changing the ID of an object, since this requires that all references to this object using the old ID value are changed as well. Changing all references may be difficult to achieve, even though SQL provides special support for such ID changes by means of its ON UPDATE CASCADE clause for the change management of foreign keys.

The following diagram shows how to define a frozen value constraint for the isbn attribute:

Get hands-on with 1200+ tech skills courses.