KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have two tables: person: id serial primary key, name varchar(64) not null task: tenant_id integer not null references person (id) on delete cascade, customer_id integer not null references person (id) on delete restrict (They have a lot more columns than that, but the rest aren't relevant to the question.) The problem is, I want to cascade-delete a task when its tenant person is deleted. But when the tenant and the customer are the same person, the customer_id foreign key constraint will restrict deletion. My question has two parts: Is temporarily disabling the second foreign key my only option? If so, then how do I do that in PostgreSQL?
Tags (comma-separated)
Save Edits
Cancel