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

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

android - How to create dynamically Fragment pager adapter -

1111. appearing after print sequence - php -