Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MySQL foreign key problems

Posted on 2004-04-30
4
Medium Priority
?
2,831 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 90 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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

722 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