Hello,

Is it possible to use a field in a VIEW as the foreign key for another
table? Something like:

CREATE TABLE "stuff" ("id" INTEGER PRIMARY KEY NOT NULL, "desc" TEXT);
CREATE TABLE "morestuff" ("id" INTEGER PRIMARY KEY NOT NULL, "desc" TEXT);
CREATE VIEW "allstuff" AS SELECT id, desc FROM stuff UNION SELECT id, desc
FROM morestuff;
CREATE TABLE "thistable" ("myid" INTEGER PRIMARY KEY AUTOINCREMENT NOT
NULL, "id" INTEGER, "desc" TEXT, FOREIGN KEY(id) REFERENCES allstuff(id));

If I try to do something like that, when I go to INSERT into "thistable" I
get a foreign key violation, even though doing a SELECT against "allstuff"
shows the row with the "id" value that matches the INSERT into "thistable".

Thanks!
Tom
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to