Reputation: 203
I've got a problem with my sql command.
I created two related tables.
String CREATE_TABEL_1="CREATE TABLE "+TABLE_NAME2+"(idCategory INTEGER PRIMARY KEY AUTOINCREMENT, categoryName TEXT, pictureId INTEGER)";
String CREATE_TABLE_2="CREATE TABLE "+TABLE_NAME+"(idCategory INTEGER, date TEXT, weekOfYear INTEGER, time REAL," +
"FOREIGN KEY (idCategory) REFERENCES Category(idCategory) ON UPDATE CASCADE ON DELETE CASCADE)";
And when I want to delete i.e. category "WORK" from Category (table 1), it's removed but work's id is not deleted from Table 2.
Upvotes: 1
Views: 112
Reputation: 152927
By default, foreign keys is supported by syntax but not enforced.
You need to enable foreign keys support with
PRAGMA foreign_keys=on;
Upvotes: 4