I think your relationship is backwards. Basically, you want deactivations
(or some other table) to have the primary key. Then, this can be shared among the other tables:
create table deactivations (
deactivationId int auto_increment primary key,
. . .
);
create table config1 (
config1Id int primary key,
. . .
constraint fk_config1_config1Id foreign key (config1Id) references deactivations(deactivationId)
);
create table config2 (
config2Id int primary key,
. . .
constraint fk_config2_config2Id foreign key (config2Id) references deactivations(deactivationId)
);
This is not 100% what you need, because a deactivationId
could be shared between the two tables. There are ways around this, but alas in MySQL, such a check requires triggers.
If you still want to go with your solution, you can use a generated column:
create table deactivations (
config1Id int,
config2Id int,
id int generated always as (coalesce(config1Id, config2Id)),
constraint fk_deactivations_config1Id as foreign key (config1Id) references config1(config1Id),
constraint fk_deactivations_config2Id as foreign key (config2Id) references config2(config2Id)
);
Unfortunately, MySQL does not support check constraints, so you require a trigger to guarantee that exactly one but not both of the ids are not null.