Example of Check Constraints
Example: Workaround for when subqueries not permitted in CHECK constraints
CREATE FUNCTION NO_MORE_THAN_20000_ENROLMENTS ( )
RETURNS BOOLEAN;
RETURN (SELECT COUNT (*) FROM IS_ENROLLED_ON) <= 20000;
ALTER TABLE IS_ENROLLED_ON
ADD CONSTRAINT MAX_ENROLMENTS
CHECK (NO_MORE_THAN_20000_ENROLMENTS ( ));