Unanswered: Primary key and foreign key shares the same field?
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,
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;