dbs assertion and trigger

dbs assertion and trigger - Assertions

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Assertions An  assertion  is a predicate expressing a condition that we wish the database always to  satisfy. An assertion in SQL takes the form create assertion  <assertion-name>  check  <predicate> When an assertion is made, the system tests it for validity, and tests it again on every  update that may violate the assertion o This testing may introduce a significant amount of overhead; hence assertions  should be used with great care. Asserting        for all X, P(X)  is achieved in a round-about fashion using          not exists X such that not P(X) o Assertion Example     The sum of all loan amounts for each branch must be less than the sum of all account  balances at the branch. o create assertion  sum-constraint  check  (not exists (select * from  branch          where (select sum (amount)  from  loan where  loan.branch-name = branch.branch-name)   >=  (select sum (amount)  from  account   where  loan.branch-name = branch.branch-name))); Assertion Example Every loan has at least one borrower who maintains an account with a minimum balance  or $1000.00 create assertion  balance-constraint  check     (not exists (
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/25/2010 for the course CMPN SEM4 taught by Professor Thakur during the Spring '07 term at University of Mumbai.

Page1 / 4

dbs assertion and trigger - Assertions

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online