I have two tables in my database named user and account. The user table has a foreign key column named account_id which is bound to the id column of table account.
More specifically, the simplified database structure is as follows:
CREATE TABLE account (
id INTEGER PRIMARY KEY,
name VARCHAR NOT NULL UNIQUE
);
CREATE TABLE "user" (
id INTEGER PRIMARY KEY,
login VARCHAR NOT NULL UNIQUE,
pass VARCHAR NOT NULL,
account_id INTEGER NOT NULL,
CONSTRAINT account_fk FOREIGN KEY (account_id)
REFERENCES account (id) ON DELETE CASCADE ON UPDATE CASCADE NOT DEFERRABLE
);
I'd like to know whether it is possible to delete a row of table user without also deleting the account being referenced by the specific record?
Whenever I try to delete an account, the related rows in table user are deleted as well (due to the ON DELETE CASCADE clause). However, I need the same series of events taking place in the other direction as well.