mySQL foreign keys

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

mySQL foreign keys

Post by GeXus »

Does anyone know if this is supported in mySQL? Without innoDB.... which I'm not even entirely sure what that is.

Code: Select all

FOREIGN KEY (user_id) REFERENCES reviewing (user_id) on delete cascade
This would be amazing if supported!
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

With mysql you have different types of table that you can use.

myisam (default)
innodb
heap
ndb

innodb supports foreign keys i believe, ndb might also
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

mikeq wrote:With mysql you have different types of table that you can use.

myisam (default)
innodb
heap
ndb

innodb supports foreign keys i believe, ndb might also
Interesting, so if I wanted to do foreign keys I would use an innoDB type, is that commonly used? and is it packaged with mysql?
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

http://www.mysqlperformanceblog.com/200 ... ks-part-1/

Just read this article, appears that innoDB is substantially faster then myISAM
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

The other engines can use foreign keys as well, although artificially created.
GeXus
Forum Regular
Posts: 631
Joined: Sat Mar 11, 2006 8:59 am

Post by GeXus »

Well, I decided to give it a try, I changed all my tables to innodb and started using the constraints... i love it!
Post Reply