Integrity and Security:Assertions

Assertions

An assertion is a predicate expressing a condition that we wish the database always to satisfy. Domain constraints and referential-integrity constraints are special forms of assertions. We have paid substantial attention to these forms of assertion because they are easily tested and apply to a wide range of database applications. However, there are many constraints that we cannot express by using only these special forms. Two examples of such constraints are:

• The sum of all loan amounts for each branch must be less than the sum of all account balances at the branch.

• Every loan has at least one customer who maintains an account with a mini- mum balance of $1000.00.

An assertion in SQL takes the form

create assertion <assertion-name> check <predicate>

Here is how the two examples of constraints can be written. Since SQL does not provide a “for all X, P (X)” construct (where P is a predicate), we are forced to implement the construct by the equivalent “not exists X such that not P (X)” construct, which can be written in SQL. We write

image

When an assertion is created, the system tests it for validity. If the assertion is valid, then any future modification to the database is allowed only if it does not cause that assertion to be violated. This testing may introduce a significant amount of overhead if complex assertions have been made. Hence, assertions should be used with great care. The high overhead of testing and maintaining assertions has led some system developers to omit support for general assertions, or to provide specialized forms of assertions that are easier to test.

Comments

Popular posts from this blog

Database System Architectures:Parallel Systems.

DATABASE DESIGN -2 part2

Database System Architectures:Network Types