Solved

MySQL foreign key problems

Posted on 2004-04-30
4
2,802 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
I use MySQL for many of my development projects in a Windows environment. To manage my databases (and perform queries) for years I used a tool called MySQL administrator.  This tool has since been replaced by MySQL Workbench. So I decided to m…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

920 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

12 Experts available now in Live!

Get 1:1 Help Now