mardi 25 mars 2014

Composite key foreign key


Vote count:

0




I have two tables called CarDeals and Cars


This is how the DDL looks like



CREATE TABLE Cars (
CarID VARCHAR(10),
CarNo VARCHAR(15),
PRIMARY KEY (CarID, CarNo)
);

CREATE TABLE CarDeals (
CarDealID VARCHAR(6),
CarID VARCHAR(10),
CarNo VARCHAR(15),
FOREIGN KEY (CarID, CarNo) REFERENCES Cars (CarID, CarNo)
);


Now MySQL does not like this one bit. How do I fix this error so that I could fix this composite key?


I would greatly appreciate it if someone could sort out my coding.


Thanks



asked 30 secs ago






Aucun commentaire:

Enregistrer un commentaire