A system for enabling a user of a relational database to define and
enforce ordered check constraints to insure that defined logical
relationships are maintained between data values in pairs of adjacent
rows when adjacency is defined by some ordering of the data. These
inter-row conditions, here called "ordered check constraints," are
expressed by a logical expressions which define a required relationship
between the attributes of a given row and its adjacent row or rows.
Arbitrarily complex expressions involving these sets of attributes can be
formed to model the constraints of interest. These expressions can be
created by the database in support of, for example, traditional primary
key or uniqueness constraints, or they can be provided by the database
user to model new more complex constraints such as a requirement that
there be no gaps in a list of serial numbers. These constraints can then
be efficiently supported in the presence of a b-tree or another ordered
index structure by identifying any inserted, updated or deleted rows and
evaluating the expression in the context of those rows and any associated
adjacent rows. This approach is similar to that typically used in
existing database systems to support primary key and uniqueness
constraints, providing the user with the ability to model a much richer
set of constraints using a generalized expression which extends and
enhances the functionality of check constraints to permit relationships
of data in different rows to be defined and enforced.