create assertion assertion-name check predicate
Ensuring the sum of loan amounts for each branch is less than the sum of all account balances at the branch.
create assertion sum-constraint check(not exists (select * from branch
where (select sum)amount) from loan
where (loan.bname = branch.bname >=
(select sum)amount) from account
where (account.bname = branch.bname)))
create assertion balance-constraint check(not exists (select * from loan L
(where not exists (select *
from borrower B, depositor D, account A
where L.loan# = B.loan# and B.cname = D.cname
and D.account# = A.account# and A.balance >= 1000 )))
If the assertion is valid, any further modification to the database is allowed only if it does not cause that assertion to be violated.
This testing may result in significant overhead if the assertions are complex. Because of this, the assert should be used with great care.