On Dec 4, 2009, at 12:31 PM, Paul Shaffer wrote:

> Below are 3 tables. When I delete a row in Item with related rows in
> Item_attribute I get the dreaded "foreign key mismatch" error. I've  
> read
> through the documentation and don't see what I'm doing wrong.

There are no FK mismatches in the three table definitions here.

Maybe the problem is in a different part of the schema. Any other FK
constraints reference table [Item]? Any ON DELETE triggers on table
[Item]?


> sqlite v 1.6.20
>
> CREATE TABLE [Item_attribute] (
>    "ItemID"        integer NOT NULL,
>    "AttributeID"        integer NOT NULL,
>    PRIMARY KEY ([ItemID], [AttributeID])
> ,
>    FOREIGN KEY ([AttributeID])
>        REFERENCES [Attribute]([AttributeID]) ON DELETE CASCADE,
>    FOREIGN KEY ([ItemID])
>        REFERENCES [Item]([ItemID]) ON DELETE CASCADE
> )
>
>
> CREATE TABLE [Item] (
>    "ItemID"        integer PRIMARY KEY AUTOINCREMENT NOT NULL,
>    "ItemName"        varchar(255) NOT NULL COLLATE NOCASE DEFAULT ''
> )
>
> CREATE TABLE [Attribute] (
>    "AttributeID"        integer PRIMARY KEY AUTOINCREMENT NOT NULL,
>    "Name"        varchar(255) NOT NULL COLLATE NOCASE DEFAULT ''
>
> )
>
>
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

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

Reply via email to