next up previous
Next: Referential Integrity Up: Integrity Constraints Previous: Integrity Constraints

Domain Constraints

  1. A domain of possible values should be associated with every attribute. These domain constraints are the most basic form of integrity constraint.

    They are easy to test for when data is entered.

  2. Domain types
    1. Attributes may have the same domain, e.g. cname and employee-name.
    2. It is not as clear whether bname and cname domains ought to be distinct.
    3. At the implementation level, they are both character strings.
    4. At the conceptual level, we do not expect customers to have the same names as branches, in general.
    5. Strong typing of domains allows us to test for values inserted, and whether queries make sense. Newer systems, particularly object-oriented database systems, offer a rich set of domain types that can be extended easily.
  3. The check clause in SQL-92 permits domains to be restricted in powerful ways that most programming language type systems do not permit.
    1. The check clause permits schema designer to specify a predicate that must be satisfied by any value assigned to a variable whose type is the domain.
    2. Examples:

       create domain hourly-wage numeric(5,2)
      

      constraint wage-value-test check(value >= 4.00)

      Note that ``constraint wage-value-test'' is optional (to give a name to the test to signal which constraint is violated).

       create domain account-number char(10)
      

      constraint account-number-null-test check(value not null)

       create domain account-type char(10)
      

      constraint account-type-test check(value in (``Checking'', ``Saving''))



Osmar Zaiane
Tue Jun 9 15:12:55 PDT 1998