Two simple tables:
"CREATE TABLE categories(
_id integer primary key autoincrement,
name text not null
);"
"CREATE TABLE expenses (" +
"_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, " +
"category_name TEXT REFERENCES categories(name) ON UPDATE CASCADE , " +
"value FLOAT DEFAULT 0 NOT NULL, " +
"date DATE DEFAULT (DATETIME('NOW')) NOT NULL
);"
I’m wondering why "UPDATE categories SET name='new name' WHERE _id=1" doesn’t change category_name in all rows in the expenses table. Documentation says it should.
Maybe the field I’m refferencing must b a primary key?
Your PK should be the “categories._id” not the “categories.name”, that’s the problem.
Try this: