How do you insert rows with circular foreign keys?

In PostgreSQL 16, you have two tables: documents and approvals. Every document must reference an approval through approval_id NOT NULL, and every approval must reference a document through document_id NOT NULL. Both columns must be foreign keys. The application inserts each row using a separate SQL INSERT statement; combining the inserts into one statement is not an option. You need to insert a new pair of related rows while preserving referential integrity. How would you define the constraints in DDL and perform the two inserts? What happens if either reference is invalid? Would the same approach work in MySQL 8.4 and ClickHouse 24.10?

ExplainDDL, keys, and normalizationMiddleBackendData EngineerQA