Tuesday, February 19, 2008

MySQL 5 foreign keys

Perhaps it was just my ignorance on all things mysql, but if you create an MyISAM table, there are no real foreign keys. It actually just creates an index when you try to create one.

If you want actual foreign keys (that reverse engineering will pick up), then change the engine to InnoDB.

This link talk about how to do this: http://dev.mysql.com/doc/refman/5.0/en/converting-tables-to-innodb.html

The mysql query browser tool will also do it for you, click on "Table Options" when editing the table. If you already have a bunch of data in the table, see the link above.

No comments: