Paste this into a new question or an answer at dba.stackexchange.com:
<!-- --> > create table p > ( a int not null > , b int > , unique (a,b) > ); > > <pre> > ✓ > </pre> <!-- --> > create table c > ( a int not null > , b int > , constraint fk_p foreign key (a,b) > references p (a,b) > on delete cascade > on update cascade > ); > > <pre> > ✓ > </pre> <!-- --> > insert into p (a,b) values (1,null); > > <pre> 1 rows affected > </pre> <!-- --> > insert into c (a,b) values (1,null), (2,null); > > <pre> 2 rows affected > </pre> <!-- --> > delete from p; > > <pre> 1 rows affected > </pre> <!-- --> > select * from c; > > <pre> > a | b > -: | ---: > 1 | <em>null</em> > 2 | <em>null</em> > </pre> *db<>fiddle [here](https://dbfiddle.uk/?rdbms=postgres_12&fiddle=11b45f56d7f6f783ad2fea116f36983f)*
back to fiddle