On Mon, Dec 06, 2010 at 06:20:13PM +0600, Dagdamor scratched on the wall: > Wodka40[Google] <martekpr...@gmail.com> писал(а) в своём письме Mon, 06 > Dec 2010 17:30:47 +0600: > > > (First of all sorry for my "inglish") > > > > 3 tables : > > Owners > > Models > > Cars > > > > My difficult is recreate a kind of "referential integrity" through FK > > > > With 2 tables not problem but with 3 cascade table ..... > > > > Owner: PK IDowner > > Models: PK IDmodel > > > > Cars: CodOwner CodModel > > > > IDowner 1-> many CodOwner > > IDmodel 1-> many CodModel > > > > I write > > CREATE TABLE [Models] (
Do you mean "CREATE TABLE [Cars]" ? > > [IDcar] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, > > [CODmodel] INTEGER NOT NULL CONSTRAINT [FKmodel] REFERENCES [Models] > > ([idmodel]) ON DELETE NO ACTION, > > [CODowner] INTEGER NOT NULL CONSTRAINT [FKowner] REFERENCES [Owners] > > ([Idowner]) ON DELETE NO ACTION, > > [DataImmatricolazione] DATE, > > [Targa] NVARCHAR(20) NOT NULL); > > > > But not works!!! > > message: > > Abort due to constraint violation. > > > > if delete one fk (random) and ....ta dah!... no error but incomplete > > simulation of "referential integrity" with 3 linked tables! > > CREATE TABLE [Models] ... REFERENCES [Models] ? > > Isn't is a recursive reference? Yes, but that's not the problem. Tables that reference themselves are perfectly normal. It is a very common way to build a tree-type structure, for example, where you might have a "parent" column that is a FK to the PK of itself. In this case, the table shown above is called "Models", but the FK REFERENCES Models ( IDModel ), which does not exist. If the example was simply copied wrong, it would help to see the CREATE TABLE statements for all three tables, plus the SQL commands (and bindings) that are causing the errors. -j -- Jay A. Kreibich < J A Y @ K R E I B I.C H > "Intelligence is like underwear: it is important that you have it, but showing it to the wrong people has the tendency to make them feel uncomfortable." -- Angela Johnson _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users