I have two tables. Device and Device_Config.
Device table has the following columns:
device_id
config_id
bla
bla2
foo
bar
And Device_config has the following columns
id
foo
bar
As you can predict, config_id on my Device table is a foreign key referencing id column on the Device_config
So I have added this constraint on my Device table.
ALTER TABLE device
ADD CONSTRAINT device_config_id_fk FOREIGN KEY (config_id)
REFERENCES device_config (id) MATCH SIMPLE
ON UPDATE NO ACTION ON DELETE CASCADE;
But this way, when a row in Device_config is deleted, the corresponding row on the Device table is deleted. However I want the opposite. When a device is deleted, I want the corresponding entry in device_config to be deleted. How can I achieve this?
device_configtodevice, i.e. adevice_idin thedevice_configtable, not the other way round