I\'ve set up two tables:
CREATE TABLE A
(
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
name TEXT
);
CREATE TABLE B
(
id INTEGER NOT NULL PRIM
The "problem" is that you have set a foreign key on table B.
foreign key(id2) references A(id)
This means that column id2
in table B references column id
in table A. Both Lord of the Rings
and Catch 22
from Table B
are linked to John
from Table A
. Therefore you cannot delete John
without first deleting these other two entries from Table B
first.
The alternative would be to remove the foreign key.
See this documentation for more details.
Table B
has rows whose foreign key references the primary key value of the Table A
row you are trying to delete so deleting it would violate the integrity of your database.
You could include ON DELETE CASCADE
in your foreign key definition. With that, when you delete an entry from Table A
, any entries in Table B
linked to the deleted row would also be deleted. Don't know if that's appropriate for your application.