Results 1 to 1 of 1
Thread: innodb and foreign keys problem
- 06-29-2009, 02:59 AM #1
Member
- Join Date
- Feb 2009
- Posts
- 12
- Rep Power
- 0
innodb and foreign keys problem
I got a problem for when i try to do a many-to-many relation (in innodb using foreign keys) between my three tables. I have created a "joined"-table for the three table to link foreign keys to. Only one table can create an foreign key the rest gets an 1005 error.
it might be that I'm doing this wrong so please correct me if i go about this the wrong way.
sample code given.
only this foreign key worksJava Code:CREATE DATABASE `trotterdb` /*!40100 DEFAULT CHARACTER SET latin1 */; CREATE TABLE `trotterdb`.`horse_race_jockey` ( `a` int(10) unsigned NOT NULL, `b` int(10) unsigned NOT NULL, `c` int(10) unsigned NOT NULL, PRIMARY KEY (`a`,`b`,`c`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `trotterdb`.`horse` ( `a` int(10) unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `trotterdb`.`jockey` ( `c` int(10) unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`c`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; CREATE TABLE `trotterdb`.`race` ( `b` int(10) unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`b`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
any other results in error 1005...even though they are the same (to me).Java Code:DROP TABLE IF EXISTS `trotterdb`.`horse`; CREATE TABLE `trotterdb`.`horse` ( `a` int(10) unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`a`), CONSTRAINT `FK_horse_1` FOREIGN KEY (`a`) REFERENCES `horse_race_jockey` (`a`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; *works fine
Is there someone who can cast some light on this matter it would be much appreciatedJava Code:DROP TABLE IF EXISTS `trotterdb`.`jockey`; CREATE TABLE `trotterdb`.`jockey` ( `c` int(10) unsigned NOT NULL AUTO_INCREMENT, PRIMARY KEY (`c`), CONSTRAINT `FK_jockey_1` FOREIGN KEY (`c`) REFERENCES `horse_race_jockey` (`c`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; *gives error 1005
Similar Threads
-
Foreign Exchange Developer NYC- Core Java, Swing, Server Side
By evanp in forum Jobs OfferedReplies: 2Last Post: 06-07-2012, 09:07 PM -
innoDB + ibatis
By vinoopraj in forum Advanced JavaReplies: 0Last Post: 05-19-2009, 09:57 AM -
How do i display foreign languages in the IDE console panel ?
By BobZ_Annapolis in forum EclipseReplies: 1Last Post: 02-20-2009, 04:16 PM -
System.getProperty with foreign language
By barakz in forum Advanced JavaReplies: 2Last Post: 11-25-2008, 04:28 AM -
Foreign Exchange NYC- Core Java, JMS, Hibernate, Spring Developer
By evanp in forum Jobs OfferedReplies: 0Last Post: 07-22-2008, 04:36 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks