I have three relations:
Recipe(id:Int, name:String), Wine(maker:String, name:String, year:Int, varietal:String, description:String), and DessertWine(maker:String, name:String, year:Int, sweetness:Int). DessertWine ISA Wine.
I setup a foreign key:
ALTER TABLE DessertWine
ADD FOREIGN KEY (maker, name, year) references Wine (maker, name, year)
ON DELETE CASCADE;
To add a DessertWine
row, the fields would be maker
, name
, year
, varietal
, description
, sweetness
), but these are split between Wine
and DessertWine
. Manually, I would add the Wine
row first, then add the DessertWine
row. Wondering how I would populate DessertWine
s from a data file using LOAD DATA INFILE
. Is there some way to add a record to both tables at the same time, perhaps using a trigger?