Can a Foreign Key be part of a Composite Primary Key for another table? Can a Foreign Key be part of a Composite Primary Key for another table? mysql mysql

Can a Foreign Key be part of a Composite Primary Key for another table?


Yes, of course. It's common for a subset of a primary key to be a foreign key. Any many-to-many table does this for instance. In your case:

CREATE TABLE ConcertDetails (  ConcertDate DATE NOT NULL,  ConcertID INT NOT NULL,  PRIMARY KEY (ConcertDate, ConcertID),  FOREIGN KEY (ConcertID) REFERENCES Concerts(ConcertID));