Hacker News new | ask | show | jobs
by pharmakom 1387 days ago
How about when the ID in a FK column has been generated outside the RDBMS but the target of the ID has not been written yet?
3 comments

You can use DEFERRABLE INITIALLY DEFERRED constraints so that the check happens when the transaction is committed.
I assume the target is externally generated too, thus can be legitimately absent.
I had this when importing test data; I found it acceptable (since it was just in development) to temporarily turn off FK checking.