Press "Enter" to skip to content

Circular Foreign Key Dependencies in Postgres

Hans-Juergen Schoenig causes and fixes a problem:

In this case, we want to store departments and employees. Every department will need a leader, and every employee will need a department. We cannot have a department without a department leader – but we cannot have an employee without a department either.

Click through to see how you can resolve this kind of paradox with Postgres.