create table Doctors
(did numeric(3)
,description varchar(20)
,referral varchar(20)
,equipment varchar(10)
, primary key(did));
insert into Doctors values
(101,'physician','fever','medicines'),
(102,'physician','cold','tablet'),
(103,'physician','cough','syrup');
create table HCOReport
(serviceid numeric(3)
,IC numeric(10)
,DC numeric(10)
,referral varchar(20) references Doctors(referral)
,primary key(serviceid)
);
insert into HCOReport values
(201,200,300,'fever'),
(202,300,200,'cold'),
(203,200,283,'cold');
create table Inventory
(itemid numeric(10)
,serviceid numeric(3) references HCOReport(serviceid)
,supplier varchar(20)
,listOfSupplies varchar(30)
);
insert into Inventory values
(101,201,'Blue Ridge','medicines'),
(102,202,'Blue Ridge','stethoscope'),
(103,201,'Blue Ridge','equipment');
create table Patients
(pid numeric(3)
,Isinsurance varchar(3)
,cost numeric(10)
, primary key(pid)
);
insert into Patients values
(501,'yes',1000),
(502,'no',10000),
(504,'no',30000);
I keep getting
there are no primary or candidate keys in the referenced table Doctors that match the referencing column list in the foreign key 'FK__HCOReport__refer__278EDA44'.