1st part Referential integrity with MySQL

Tagged: Database, MySQL Date: 26th, October 2006

Click here for Part 2

MySQL is definitely the best choice for most web applications, for it’s speed and for it’s price (or lack of the same). This is the main reason that I am writing about what was the biggest flaw of mysql (in my book) for many years, Foreign keys.

Referential integrity is very important part of database development. The term “Referential integrity” means that all referrals in database valid and that there are no invalid links between tables.

The state of referential integrity is most commonly achieved by using foreign keys. Like I mentioned mysql hasn’t supported foreign keys for very long time, mainly for the fear that it will negatively influence the speed. Recent versions support use of referential integrity through InnoDB table engine.

Few basic conditions need to be met so we can use referential integrity:

  1. Both tables must be InnoDB type
  2. Both fields used must be indexed
  3. Type of data must be similar of same

In next part I will go through short example of creating two tables linked in referential integrity in mind.

Click here for Part 2

Leave a Reply