Re: CHECK Constraint Deferrable - Mailing list pgsql-hackers

From David G. Johnston
Subject Re: CHECK Constraint Deferrable
Date
Msg-id CAKFQuwZf0We7p-7Df-Fyxrfv+cS=meF0DorEtuBWx5nhLZ+j9A@mail.gmail.com
Whole thread Raw
In response to Re: CHECK Constraint Deferrable  (Himanshu Upadhyaya <upadhyaya.himanshu@gmail.com>)
Responses Re: CHECK Constraint Deferrable
List pgsql-hackers
On Friday, July 7, 2023, Himanshu Upadhyaya <upadhyaya.himanshu@gmail.com> wrote:
I can think of one scenario, as below

1) any department should have an employee
2)any employee should be assigned to a department
so, the employee table has a FK to the department table, and another check constraint should be added to the department table to ensure there should be one/more employees in this department. 


That isn’t a valid/allowed check constraint - it contains a prohibited reference to another table.

David J.

pgsql-hackers by date:

Previous
From: Himanshu Upadhyaya
Date:
Subject: Re: CHECK Constraint Deferrable
Next
From: Heikki Linnakangas
Date:
Subject: Re: Unlogged relations and WAL-logging