Tag Info

About

Referential integrity is a feature provided by relational database management systems to constrain data so that it cannot hold invalid values. The normal mechanism employed for this is a foreign key, although other means can be used.

A foreign key refers one more columns on a table to a primary or unique identifier on another table. The key precludes the columns on that table from holding values that are not present at the source.

For example, one could have a 'currency' table that holds a list of three letter ISO currency codes. A financial transaction could have a 'currency_code' column that can contain an ISO code describing the currency of the transaction.

Placing a foreign key on the currency column in the transaction table that refers to the currency code table prevents that column from holding a value that is not present in the list of currencies. The foreign key constraint enforces referential integrity by preventing values that do not match the list of valid currencies from being entered into the transactions table.

history | show excerpt | excerpt history