Solved

MySQL foreign key problems

Posted on 2004-04-30
4
2,796 Views
Last Modified: 2008-03-03
is it true that mysql does not support foreign keys? i am using the mysql server and mysql control center currently and it works perfectly. and today i knew that it does not support foreign key, how can i link a primary key to another table? if i cant do so, does this mean i have to update 2 tables at once or have to create more tables?
0
Comment
Question by:otyew
  • 2
4 Comments
 
LVL 7

Expert Comment

by:culshaja
ID: 10960846
This is from the manual:

'In MySQL Server 3.23.44 and up, the InnoDB storage engine supports checking of foreign key constraints, including CASCADE, ON DELETE, and ON UPDATE. See section 16.7.4 FOREIGN KEY Constraints.

For storage engines other than InnoDB, MySQL Server parses the FOREIGN KEY syntax in CREATE TABLE statements, but does not use or store it. In the future, the implementation will be extended to store this information in the table specification file so that it may be retrieved by mysqldump and ODBC. At a later stage, foreign key constraints will be implemented for MyISAM tables as well. '

I think version 5 will support them fully. Until then if you are not using InnoDB you will have to do it manually.

James :-)
0
 
LVL 14

Accepted Solution

by:
cracky earned 30 total points
ID: 10961254
culshaja is correct, MySQL actually has quite a good Foreign Key referential integrity system in the InnoDB database storage engine.

If you need a really good tutorial on how to set this up, see:

http://www.databasejournal.com/features/mysql/article.php/2248101
0
 

Author Comment

by:otyew
ID: 10967619
dear cracky,

i have heard of innodb and even recommeded to use it too but i do not know what it is. issit already available in the mysql? or i have to download it? i am fairly new to mysql
0
 
LVL 14

Expert Comment

by:cracky
ID: 10967659
InnoDB is already active in current MySQL distributions.

If you are new to MySQL, I would recommend installing phpMyAdmin on your webserver to make your life a lot easier:

http://www.phpmyadmin.net/

If you follow the tutorials above, you will be able to get started pretty quickly. I use InnoDB in my applications and it works great.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now