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.

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

Reply via email to