create table p (id serial primary key, val text);
create table c (id serial primary key, p_id int not null references p(id) on delete no action deferrable, val text);
insert into p (val) values ('a'), ('b');
insert into c (p_id, val) values (1, 'a1'), (1, 'a2'), (1, 'a3'), (2, 'b1');
begin;
set constraints all deferred;
delete from p where id = 2;
delete from c where p_id = 2;
commit;