> why returns the "INSERT INTO a" not an error while the "INSERT INTO > b" does? How > corresponds this behaviour to the concept of FOREIGN KEYS?
> CREATE TABLE a( > id INTEGER PRIMARY > KEY > AUTOINCREMENT, > id_staff_editor INTEGER NOT NULL, > FOREIGN KEY(id_staff_editor) REFERENCES a(id) > ); > > INSERT INTO a(id_staff_editor) VALUES(1); > > CREATE TABLE b( > id INTEGER PRIMARY > KEY > AUTOINCREMENT, > id_staff_editor INTEGER NOT NULL, > FOREIGN KEY(id_staff_editor) REFERENCES b(id) > ); > > INSERT INTO b(id_staff_editor) VALUES(2); The key statement is in the second paragraph here: http://www.sqlite.org/foreignkeys.html#fk_deferred "If a statement modifies the contents of the database so that an immediate foreign key constraint is in violation at the conclusion the statement, an exception is thrown and the effects of the statement are reverted." At the conclusion of your two insert statements, table "a" contains (1, 1) and table "b" contains (1, 2). Since the contents of table "b" violate the FK constraint, an exception is thrown. Dan. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users