I was reading most common database design mistakes made by developer Q&A on stackoverflow. At first answer there was phrase about exclusive arc:
An exclusive arc is a common mistake where a table is created with two or more foreign keys where one and only one of them can be non-null. Big mistake. For one thing it becomes that much harder to maintain data integrity. After all, even with referential integrity, nothing is preventing two or more of these foreign keys from being set (complex check constraints notwithstanding).
I really don't understand why exclusive arc is evil. Probably I didn't understand the basics of it. Is there any good explanation on exclusive arcs?
alter table mytable add constraint myconstraint check ((col1 is not null and col2 is null and col3 is null) or (col1 is null and col2 is not null and col3 is null) or (col1 is null and col2 is null and col3 is not null))
. I don't like exclusive arcs but they can be enforced with a check constraint. Of course the FK constraint must also be present. – Tulains Córdova Dec 31 '14 at 21:31check ((col1 is not null)::integer + (col2 is not null)::integer + (col3 is not null)::integer = 1)
? – Reinstate Monica Jun 27 '18 at 16:49