


The integrity of data is supported in ADABAS by declarations using powerful DDL statements and options.
Integrity rules for tables:
PRIMARY KEY is the primary key of a table. ADABAS ensures the uniqueness of the primary key.
UNIQUE is a set of columns whose values uniquely identify a row in a table.
NOT NULL is a mandatory column. ADABAS ensures that this column is always set to values.
DEFAULT assigns a default value specific to a column.
CHECK The CHECK definition checks the row of the table affected by INSERT and UPDATE. In a CHECK rule, a WHERE condition can be formulated for this row which has to be satisfied.
FOREIGN KEY Referential integrity constraints between tables are expressed by specifying the foreign key (inclusive ON DELETE).
In addition to value lists or value ranges, the CHECK rule allows complex conditions to be formulated which can also refer to other columns in the same row.
To be able to formulate extensive business data models with ADABAS, domain definitions are supported as well as table definitions. Domains are user-defined data types which can be used in CREATE TABLE statements instead of the predefined data types (CHAR, FIXED, FLOAT, ...). By using domains, integrity rules can be defined on the level of data elements and their use in the definition of tables helps in modelling the data uniformly and consistently.
Example:
CREATE DOMAIN itemno CHAR(12) CHECK LIKE '????.???.???'
CREATE TABLE item(
itno itemno,
itname CHAR(30) NOT NULL,
entrydate DATE NOT NULL,
purchaseprice FIXED(6,2) NOT NULL
CHECK purchaseprice > 0,
sellprice FIXED(8,2) NOT NULL
CHECK sellprice > purchaseprice,
PRIMARY KEY (itno))
Data integrity in ADABAS can be ensured in most cases by means of declarative integrity rules. Only in exceptional cases is it necessary to formulate procedural triggers to monitor highly complex integrity conditions. In general, the use of declarative rules has advantages over a procedural formulation via triggers because ADABAS ensures, when an integrity rule is modified, that the existing data set corresponds to the new integrity rule. Such a check cannot be carried out for procedurally formulated rules.


