4 5 5 What is Database Referential Integrity

Visual LANSA

4.5.5 What is Database Referential Integrity?

Referential Integrity is an important feature within an application database design. Referential Integrity refers to the ability of the database to keep related data from being corrupted. The data references between files must remain intact. For example in the Personnel System demonstration application database, all of the records in the Section file require a Department Code. These Department Codes must exist in the Department file. If this reference is lost, the database is considered to be corrupted and referential integrity is broken.

Referential Integrity means that two specific database rules must exist between files:

1.  Do not delete data required by another file.
You must check that there are no records in related files that require the record which you are deleting.

2.  Do not add incomplete data to a file.
You must check that the related information exists in another file before adding information to a file.

These two rules describe data dependencies from the perspective of each file involved in the relationship. Referential integrity works in two directions and is sometimes described as "forward" and "backward" referential integrity. This concept is similar to access routes.  File1 has a relationship to File2, and File2 has a relationship to File1. In order to build referential integrity into your database, you must have a good understanding of the application business rules.

LANSA implements database referential integrity using file rules in the repository so that your application is independent of the database used. Independence is a major advantage when deploying your application.

Also See

Personnel Demonstration Application

Referential Integrity Example

Ý 4.5 File Rules & Triggers Development