On Wed, 13 Oct 2010 12:55:40 +0200, TP
<[email protected]> wrote:

> Is this legal to have a foreign key
> that references several tables?

It is legal, but it is uncommon or even very rare.

Why? Well, a foreign key column (id_toto2_and_toto3)
identifies a row (tuple) in the referred table (toto2)
typically by it's primary key (id_toto2) or some other
unique column (a candidate key).

If that same column (id_toto2_and_toto3) also is a foreign
key to another table (toto3), it identifies a row in the
same way in that second table _with_ the _same_ identity.

That is to say, any value in id_toto2_and_toto3 has a
corresponding row in both toto2 and toto3.

You have to ask yourself if toto2 and toto3 shouldn't be
combined into one table.

As far as I can tell, the only reason to not combine them
would be some performance optimization. One should only do
that to solve real performance problems, not in the initial
design.
-- 
  (  Kees Nuyt
  )
c[_]
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to