[sqlite] multiple foreign key

2010-10-13 Thread TP
Hello, I have another borderline question about SQL in SQLite. Look at the following example --- PRAGMA foreign_keys = ON; CREATE TABLE toto1 ( id_toto1 INTEGER PRIMARY KEY , id_toto2_and_toto3 INTEGER NOT NULL ,

Re: [sqlite] multiple foreign key

2010-10-13 Thread Pavel Ivanov
Is this legal to have a foreign key that references several tables? Why not? I'd say it's a very bad database design (or extremely rare and questionable reason to do that) but there's nothing wrong in it from SQL point of view. Pavel On Wed, Oct 13, 2010 at 6:55 AM, TP

Re: [sqlite] multiple foreign key

2010-10-13 Thread TP
Pavel Ivanov wrote: Is this legal to have a foreign key that references several tables? Why not? I'd say it's a very bad database design (or extremely rare and questionable reason to do that) but there's nothing wrong in it from SQL point of view. Thanks Pavel. I'm rather new at SQL. I

Re: [sqlite] multiple foreign key

2010-10-13 Thread Kees Nuyt
On Wed, 13 Oct 2010 12:55:40 +0200, TP paratribulati...@free.fr 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

Re: [sqlite] multiple foreign key

2010-10-13 Thread TP
Kees Nuyt wrote: 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