lpxxfaintxx Posted March 6, 2006 Share Posted March 6, 2006 If I'm not mistaken, MySQL does not support foreign keys. Are there any alternatives to it, and if there is will you please enlighten me with tutorials and links?Regards,-lpxxfaintxx Quote Link to comment Share on other sites More sharing options...
obsidian Posted March 6, 2006 Share Posted March 6, 2006 foreign keys ARE supported in mysql. check out [a href=\"http://dev.mysql.com/doc/refman/4.1/en/ansi-diff-foreign-keys.html\" target=\"_blank\"]this page[/a] in the mysql manual for more information, but basically, you'd want to set one up in the creation of your table like this:[!--sql--][div class=\'sqltop\']SQL[/div][div class=\'sqlmain\'][!--sql1--]CREATE TABLE posts(id int(11) auto_increment primary key,user_id int(11) REFERENCES users(id) ON [span style=\'color:blue;font-weight:bold\']DELETE[/span] CASCADE);[!--sql2--][/div][!--sql3--]when you use the REFERENCES keyword, you are creating a foreign key constraint which will allow you to run cascades and on update and on delete queries. Quote Link to comment Share on other sites More sharing options...
lpxxfaintxx Posted March 6, 2006 Author Share Posted March 6, 2006 Err... do you need access to anything to install InnoDB? Quote Link to comment Share on other sites More sharing options...
fusionpixel Posted March 6, 2006 Share Posted March 6, 2006 [!--quoteo(post=352215:date=Mar 6 2006, 02:55 PM:name=lpxxfaintxx)--][div class=\'quotetop\']QUOTE(lpxxfaintxx @ Mar 6 2006, 02:55 PM) [snapback]352215[/snapback][/div][div class=\'quotemain\'][!--quotec--]Err... what if you don't have InnoDB? And what [i]is[/i] InnoDB?[/quote]How do you know if you dont have InnoDB if you dont know what InnoDB is ;) ?[a href=\"http://dev.mysql.com/doc/refman/5.0/en/innodb.html\" target=\"_blank\"]Find more about InnoDB here[/a]just FYI InnoDB is installed by default. Quote Link to comment Share on other sites More sharing options...
obsidian Posted March 6, 2006 Share Posted March 6, 2006 if you have MySQL installed, you have InnoDB:[quote]Starting from MySQL 3.23.44, InnoDB features foreign key constraints.[/quote]if you want to get really technical about what the engine actually is, you can read more about it at [a href=\"http://www.innodb.com/\" target=\"_blank\"]http://www.innodb.com/[/a].suffice to say (for all intents and purposes), it is the engine that handles your queries and constraints for you. it basically a way of storing the data. the alternative i'm most familiar with in mysql is MyISAM, and if you're running MySQL 5+, you should have FOREIGN KEY constraints in that format as well.you're actually treading into an area that you'll probably get as much help for directly from the manual or google as you will from most users on here. ;-) Quote Link to comment Share on other sites More sharing options...
lpxxfaintxx Posted March 6, 2006 Author Share Posted March 6, 2006 Hah, thanks for the extremely helpful replies guys! ;) Quote Link to comment Share on other sites More sharing options...
obsidian Posted March 6, 2006 Share Posted March 6, 2006 [!--quoteo(post=352221:date=Mar 6 2006, 04:09 PM:name=lpxxfaintxx)--][div class=\'quotetop\']QUOTE(lpxxfaintxx @ Mar 6 2006, 04:09 PM) [snapback]352221[/snapback][/div][div class=\'quotemain\'][!--quotec--]Hah, thanks for the extremely helpful replies guys! ;)[/quote]lol... glad it was helpful ;-)... we're getting into an area where i feel like i'm spewing out all sorts of references, but i don't know that i could be much more informative than what i already wrote, so i'm glad it helped Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.