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
Selecting the right ON DELETE action is a data-retention decision, not a syntax choice. RESTRICT protects dependents, CASCADE removes lifecycle children, and SET NULL preserves rows with optional references.
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