MySQL says:
the alter table statement conflicted with the FOREIGN KEY constraint "FK_PATIENTS_VICTIMS". The conflict occurred in the database " my_database", table "dbo.victims", column "victim_id'.
I tried to alter the table by inputting;
ALTER TABLE PATIENTS WITH NOCHECK ADD CONSTRAINT [FK_PATIENTS_VICTIMS] FOREIGN KEY(VICTIM_ID) REFERENCES VICTIM(ID)
Patients table
create table patients(
victim_id int(4),
blood_type varchar(4),
vaccinations varchar(100),
assigned_practitioner int(10),
hospital_id int(10),
insurance_id int(10),
symptoms varchar(200);
Victims table
create table victims(
victim_id int(4) primary key,
first_name varchar(20),
last_name varchar(20),
sex char(1) constraint persons_sex_ck check(sex IN('F','M')),
PHONE_NUMBER varchar(20),
DOB varchar(13),
address varchar(30),
city varchar(20),
zip int(5),
state varchar(5)
);
CodePudding user response:
You have:
REFERENCES VICTIM(ID)
You need:
REFERENCES VICTIMS(Victim_ID)