0

I have the basic setup depicted in this SQL Fiddle. In short, I have a table which has a candidate foreign key whose value may ID a record in one of several tables (if it's not NULL, that is)! How am I supposed to tell Oracle (11g r2) about this, or is putting a foreign key constraint on such a column a hopeless cause?

(Note: this is not due to any sort of partitioning -- the equivalents to foo, bar, and baz in the real DB have completely different schemas save for them all having IDs that can be guaranteed to not overlap.)

LThode
  • 1,843
  • 1
  • 17
  • 28

1 Answers1

0

This question is very similar to Foreign Key to multiple tables

That question's top answer proposes many good solutions, but in your case a standard practice you could follow is to have a column for the ids to each of your tables(bar_id, baz_id, and foo_id).

Community
  • 1
  • 1
nick_de_veaux
  • 101
  • 1
  • 4