sql - Creating a reverse cascade constraint in Postgres -


i have couple of tables , pivot table links them so:

create table table1 {   id serial not null }  create table table2 {   id serial not null }  create table table1_table2 {   table1_id,   table2_id,   constraint table1_table2_table1_id_foreign foreign key (table1_id)     references table1 (id) match simple     on update no action on delete no action,   constraint table1_table2_table2_id_foreign foreign key (table2_id)     references table2 (id) match simple     on update no action on delete no action, } 

as can see, when delete entry pivot table, want make sure neither table1 nor table2 affected; however, want opposite true. if delete entry table1, want delete associated entries pivot table. same goes table2.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -