Thursday, 17 March 2011

Database Referential Integrity

Database Referential Integrity is something everyone should know. I know I do; it’s like knowing the colour green, it’s something that is obvious, in fact it’s so obvious that I couldn’t explain it the other day when asked. So here is a brief overview and a quick link to the more in-depth wikipedia explanation.

Referential Integrity is also known as foreign key integrity, which is a more descriptive, ‘does what it says on the tin’ type of name.

To summarize: given two tables in a database, A and B, where A contains a foreign key to B, then for every row in A with a foreign key, there MUST be the corresponding row in B for Referential Integrity to exist. If you don’t have Referential Integrity, then your database is broken...

No comments: