I'm in a scenario where two child tables (Visual and Hearing Devices) would take in data about the parent (Device) Table and I need what ever primary key (The ID) which is defined in the Visual Device or Hearing Device tables to be set as the primary key in the parent table (Also the ID). I can't figure out how to make this happen. I'm thinking whether you can use an IF condition?
CREATE TABLE w1742302_visual_Device (
deviceCatalogID varchar(5),
frBrand varchar(20),
frModel varchar(20),
lensSerialN varchar(20),
lensVisionType varchar(20),
lensTint set('1','2','3'),
lensThinnessLevel set('1','2','3'),
CONSTRAINT pk_visionDevice_catalogID PRIMARY KEY (deviceCatalogID);
);
CREATE TABLE w1742302_hearing_Device (
deviceCatalogID varchar(5),
hdMake varchar(20),
hdModel varchar(20),
CONSTRAINT pk_hearingDevice_catalogID PRIMARY KEY (deviceCatalogID)
);
CREATE TABLE w1742302_device (
deviceCatalogID varchar(5),
deviceCatalogName varchar(20),
deviceDescription varchar(300),
availabilityStatus boolean,
CONSTRAINT pk_device_catalogID PRIMARY KEY (deviceCatalogID)
CONSTRAINT fk_device_catalogID PRIMARY KEY (deviceCatalogID) references ????
);
Note that the references ??? is because idk what to put there