[prev] 20 [next]

Data Definition (cont)

Constraints are an important aspect of data definition:
  • attribute (column) constraints
  • tuple constraints
  • relation (table) constraints
  • referential integrity constraints
Examples:

create table Employee (
   id      integer primary key,
   name    varchar(40),
   salary  real,
   age     integer check (age > 15),
   worksIn integer references Department(id),
   constraint PayOk check (salary > age*1000)
);

On each attempt to change data, DBMS checks constraints.