Re: [sqlite] Foreign keys + NATURAL JOIN

2009-10-17 Thread Darren Duncan
Kristoffer Danielsson wrote: > Thanks. > > This leads me to the next question. > > Why does the statement below yield a cartesian product? > > SELECT COUNT(*) FROM t1 NATURAL JOIN t1; -- Slw! It doesn't. In fact "t1 NATURAL JOIN t1" would do the exact opposite, because *all* of the co

Re: [sqlite] Foreign keys + NATURAL JOIN

2009-10-17 Thread Kristoffer Danielsson
ite-users@sqlite.org > Subject: Re: [sqlite] Foreign keys + NATURAL JOIN > > Kristoffer Danielsson wrote: > > Q: Does foreign keys affect NATURAL JOINs? > > > > I haven't tested this. Does this NATURAL JOIN produce an inner join or a > > cartesian product? > &g

Re: [sqlite] Foreign keys + NATURAL JOIN

2009-10-17 Thread Darren Duncan
Kristoffer Danielsson wrote: > Q: Does foreign keys affect NATURAL JOINs? > > I haven't tested this. Does this NATURAL JOIN produce an inner join or a > cartesian product? The presence of foreign key constraints has no effect on the results of any queries, using natural joins or otherwise. A n

[sqlite] Foreign keys + NATURAL JOIN

2009-10-17 Thread Kristoffer Danielsson
Q: Does foreign keys affect NATURAL JOINs? SQLite 3.6.18 sample (NO foreign keys): CREATE TABLE t1 (a INTEGER PRIMARY KEY, b INTEGER NOT NULL); CREATE TABLE t2 (x INTEGER PRIMARY KEY, y INTEGER NOT NULL); SELECT * FROM a NATURAL JOIN b; -- Cartesian product! SQLite 3.6.19 sample (using