HeyaI tried to create some tables and got Error 1776. I've read about it but can't seem to find out why it doesn't work.This is the code for the tables "involved"create table Employee(SocialSecurity varchar(12) not null,Name varchar(20),City varchar(10),Street varchar(20),ZipCode varchar(5),Email varchar(20),Phone varchar(20),constraint Employee_PK primary key(SocialSecurity))create table Instructor(InstID varchar(5) not null,SocialSecurity varchar(12) not null,constraint Instructor_PK primary key(InstID,SocialSecurity),constraint SocialSecurity_FK foreign key(SocialSecurity)references Employee(SocialSecurity))create table Workout(WorkID varchar(5) not null,Name varchar(15),Date varchar(11),Time varchar(5),Length varchar(5),Level varchar(10),constraint Workout_PK primary key(WorkID))create table InstructorWorkout(InstID varchar(5) not null,WorkID varchar(5) not null,Date varchar(11),constraint InstructorWorkout_PK primary key(InstID,WorkID),constraint InstID_InsWor_FK foreign key(InstID) references Instructor(InstID),constraint WorkID_FK foreign key(WorkID) references Workout(WorkID))
The error message:There are no primary or candidate keys in the referenced table 'Instructor' that match the referencing column list in the foreign key 'InstID_InsWor_FK'.I also read that FK should reference to all the PK (meaning both InstID,SocialSecurity) but if I try with:create table InstructorWorkout(InstID varchar(5) not null,WorkID varchar(5) not null,Date varchar(11),constraint InstructorWorkout_PK primary key(InstID,WorkID),constraint InstID_InsWor_FK foreign key(InstID,SocialSecurity) references Instructor(InstID,SocialSecurity),constraint WorkID_FK foreign key(WorkID) references Workout(WorkID))
I get a different error (1769):Foreign key 'InstID_InsWor_FK' references invalid column 'SocialSecurity' in referencing table 'InstructorWorkout'.