I am trying to link these two tables but am receiving the error:
There is no unique constraint matching given keys for referenced table "accomplices".
Note Robberies is another table.
I used this to create the Accomplices table (This is when the error occurs):
CREATE TABLE info.Accomplices ( RobberID INTEGER, BankName VARCHAR, City VARCHAR, RobberyDate DATE, Share DECIMAL NOT NULL, PRIMARY KEY(RobberID, BankName, City, RobberyDate), FOREIGN KEY(BankName, City, RobberyDate) REFERENCES info.Robberies(BankName, City, RobberyDate) ); And this to create the Robbers table:
CREATE TABLE info.Robbers ( RobberID INTEGER, Nickname VARCHAR, Age INTEGER, NoYears INTEGER, PRIMARY KEY(RobberID), FOREIGN KEY(RobberID) REFERENCES info.Accomplices(RobberID), CONSTRAINT AgeCheck CHECK (Age > NoYears) ); Does the foreign key in the Robbers table need to match all components that make up the primary key in the Accomplices table?