On 30 April 2010 12:26, Karl DeSaulniers <karl@xxxxxxxxxxxxxxx> wrote: > Thanks Peter. > So what is the logic behind foreign keys? Why use them? Constraints. When using, for example, the InnoDB engine in MySQL, you can set foreign key fields on tables. These ensure that your record will always be bound to a proper record in the connected table - so, for instance, you won't find yourself in the situation that you have deleted a record from table1 but table2 still references the table1 record. Also, they're very useful for tying models together automatically, as you can deduce relationships between models by foreign keys, for instance (this is simplified but covers a lot of cases). Regards Peter -- <hype> WWW: http://plphp.dk / http://plind.dk LinkedIn: http://www.linkedin.com/in/plind Flickr: http://www.flickr.com/photos/fake51 BeWelcome: Fake51 Couchsurfing: Fake51 </hype> -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php