Rules the database refuses to break — entity integrity, referential integrity, and domain constraints — checked on every change.
Integrity constraints are rules about valid data that the database enforces *itself*, rejecting any insert, update, or delete that would break them. You never have to trust application code to keep the data clean — the DBMS checks automatically on every change. Three kinds do most of the work: entity integrity, referential integrity, and domain constraints.
age must be a non-negative number).CREATE TABLE Customer (
cust_id INT PRIMARY KEY, -- entity integrity: unique, not NULL
name VARCHAR(60) NOT NULL
);
CREATE TABLE Orders (
order_id INT PRIMARY KEY,
cust_id INT REFERENCES Customer(cust_id), -- referential integrity
amount INT CHECK (amount >= 0) -- domain constraint
);INSERT INTO Orders VALUES (7, 999, 50) when no customer 999 exists is rejected — a foreign key can't dangle. INSERT INTO Customer VALUES (NULL, 'Rae') is rejected — a primary key can't be NULL. ... amount = -5 is rejected by the CHECK domain constraint.If you delete customer 42 while orders still point at them, referential integrity would break. The DBMS follows the referential action you declared: RESTRICT blocks the delete, CASCADE deletes the dependent orders too, and SET NULL clears the foreign key to mean 'not linked'.