Reputation: 257
Does mysql server have the concept of foreign key or it's only in InnoDB? I know that InnoDB is part of mysql but it's a kind of extension. what if I wanted to use only mysql and still taking advantage of foreign keys?
Thanks
Upvotes: 0
Views: 60
Reputation: 563021
InnoDB supports foreign keys. See http://dev.mysql.com/doc/refman/5.6/en/create-table-foreign-keys.html
InnoDB is the default storage engine in MySQL 5.5 and later. You should not think of InnoDB as "a kind of extension." You should use InnoDB unless you have a specific and testable reason to use some other storage engine.
However, you're right that outside the storage engine layer, MySQL server has no implementation of foreign keys. Even the parsing of foreign key constraint syntax is delegated to the storage engine, whereas all other SQL parsing is handled at a higher level.
The NDB storage engine in MySQL Cluster also supports foreign keys.
Upvotes: 2
Reputation: 19945
The support of foreign keys in mysql depends on the storage engine.
Myisam and innodb are the main storage engines. Innodb does support foreign keys, myisam doesn't.
Upvotes: 1