pollysal Posted March 27, 2010 Share Posted March 27, 2010 i wanted to create a table name booking that have 3 composite key where 2 of the composite key is referring to each another table named customer and room. however when i wanted to create the table, it give me error. can someone tell me how can i fix this. Here's the command : CREATE TABLE booking( bookingID INT NOT NULL AUTO_INCREMENT , checkin DATETIME, checkout DATETIME, nights INT, totalprice INT, b_ic_no VARCHAR(30), b_room_no INT, PRIMARY KEY ( bookingID) , PRIMARY KEY ( b_ic_no ) REFERENCES customer( ic_no ) , PRIMARY KEY ( b_room_no ) REFERENCES room( room_no ), ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE = INNODB; Quote Link to comment https://forums.phpfreaks.com/topic/196709-composite-key-syntax-how-can-i-fix-this/ Share on other sites More sharing options...
fenway Posted March 27, 2010 Share Posted March 27, 2010 What error? Quote Link to comment https://forums.phpfreaks.com/topic/196709-composite-key-syntax-how-can-i-fix-this/#findComment-1032840 Share on other sites More sharing options...
pollysal Posted March 28, 2010 Author Share Posted March 28, 2010 i'm sorry the the super moderater for my inappropriate post....please don't be mad...i'm seriously sorry sir.. i'm using the mysql phpmyadmin. here's the error that appear : #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'REFERENCES customer( ic_no ) , PRIMARY KEY ( b_room_no ) REFERENCES room( room_' at line 10 however, here the relationship table. or, am i actually wrong in definening the syntax to create a composite key relationship? [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/196709-composite-key-syntax-how-can-i-fix-this/#findComment-1032847 Share on other sites More sharing options...
fenway Posted March 28, 2010 Share Posted March 28, 2010 You can't use a primary key as a foreign key. Quote Link to comment https://forums.phpfreaks.com/topic/196709-composite-key-syntax-how-can-i-fix-this/#findComment-1033151 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.