Other Kinds of Constraints

Other Kinds of Constraints

As already mentioned at the beginning of this section, there are other kinds of constraints one could wish to enforce in a database. We shall only touch briefly on these here, with the meat of the subject appearing in "Constraints and Triggers". Domain constraints confine the value of an attribute to be in a limited set. A simple example would be declaring the type of an attribute. A stronger domain constraint would be to declare an enumerated type for an attribute or a range of values, e.g., the length attribute for a movie must be an integer in the range 0 to 240. There is no specific notation for domain constraints in the E/R model, but you may place a notation stating a desired constraint next to the attribute, if you wish.

There are also more common types of constraints that do not fall into any of the categories mentioned in this section. For instance, we could choose to place a constraint on the degree of a relationship, such as that a movie entity cannot be connected by relationship stars to more than 10 star entities. In the E/R model, we can attach a bounding number to the edges that join a relationship to an entity set, indicating limits on the number of entities that can be attached to any one entity of the related entity set.

Representing a constraint on the number of stars per movie

Example :
The above figure shows how we can represent the constraint that no movie has more than 10 stars in the E/R model. As another example, we can think of the arrow as a synonym for the constraint "≤ 1" and we can think of the rounded arrow of "Referential Integrity in E/R Diagrams" figure as standing for the constraint "= 1".


Tags