Restrictive Constraints

Previous Next

See Also

A restrictive constraint prevents invalid data being entered in the database. For example, you could define a restrictive constraint to ensure that a tour booking date is always earlier than the tour start date.

You define a restrictive constraint as a SELECT statement. The example could be written as:

SELECT    ' ' violation

FROM    reservation r, schedtour st

WHERE    r.schedtour_id = st.schedtour_id

AND    r.book_date >= st.start_date

When you define a restrictive constraint, you also may specify a message. If the constraint selects a record, this is a violation of the business rule and the message is shown as error message.

You could also write a restrictive constraint to ensure that only valid bank account numbers can be entered. This is necessary if the individual digits in the bank account number must satisfy some proof.