Im creating a table using mySQL with two primary keys and two foreign keys using the same field.
itemA and itemB is a Primary key of another table but also used as the Primary key of table Recommendation. Is it possible to create foreign key and primary key using the same field? I had an error when creating this table. Please help me. Thanx a lot!
===========================================
CREATE TABLE Recommendation
(
itemA INT NOT NULL,
itemB INT NOT NULL,
PRIMARY KEY(itemA),
PRIMARY KEY(itemB),
INDEX(itemA),
INDEX(itemB),
FOREIGN KEY(itemA) REFERENCES Items(itemID) ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY(itemB) REFERENCES Items(itemID) ON UPDATE CASCADE ON DELETE CASCADE) TYPE=INNODB;
===========================================