I have a database where everything is linked with foreign keys, so the Postgres knows exactly how the database is layed out..
Well, Lets say I have Table1 and Table2.>
Look into on update cascade and on delete cascade.
on update cascade
on delete cascade
create table table_1 ( id integer primary key, name char(30) ); create table table_2 ( id integer primary key, table_1_id integer references table_1 on update cascade on delete cascade, detail char(30) );