Compare RESTRICT, CASCADE and SET NULL using a small isolated example, then check the actual constraint and dependent rows before changing real data.
PostgreSQL / SQL / Foreign keys / Transactions
A closer look at explicitly deferred NO ACTION checks and clearing only the optional component of a composite foreign key. These details complement the basic choice between RESTRICT, CASCADE and SET NULL.
postgresql / foreign-key / on-delete / data-retention / cascade / restrict / set-null / referential-integrity
Diagnose repeated JOIN rows by counting matching keys, checking constraints and choosing whether the result should contain orders, items or summaries.
SQL / JOIN / PostgreSQL