Skip to content

Tag: cascade

Order of cascaded deletes in postgres

I encountered a problem which makes me suspect Postgres deletes rows from dependent tables (ON DELETE CASCADE) only after it already deleted the original row. I have these tables: I created a trigger (before delete) on the function_inclusion table: Let’s say I have 2 functions and a function_inclusion: …

PostgreSQL: FOREIGN KEY/ON DELETE CASCADE

I have two tables like here: So the logic is simple, after user removes all book under category x, x gets removed from cats, i tried method above but doesn’t work, after i clean table book, table category still populated, what’s wrong? Answer A foreign key with a cascade delete means that if a rec…