On Oct 16, 2009, at 3:08 AM, Dennis Volodomanov wrote: > Dan Kennedy wrote: >> I don't think the triggers you are using can be implemented using >> foreign keys. Your triggers are basically reference counting (or >> garbage collecting, whatever you want to call it) - "when the >> number of references to a data item drops to zero, delete the >> data item". >> > Yes, exactly. >> You could add a foreign key to this schema to prevent the DataID >> column of TableA from being populated with an invalid id (one >> that does not refer to any id of the TableData table). >> > I do that check when I add entries to TableA in any case, so probably > that's best left as-is. > > Is there any gain in terms of performance when doing lookups on TableA > with JOINs with TableData when there're FOREIGN KEYs defined? Does > SQLite internally optimize queries better in such cases?
No performance gain for joins or anything like that. Using FK constraints does not affect SELECT performance. They slow down some INSERT/UPDATE/DELETE operations though. Dan. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users