Re: Constants in the foreighn key constraints

Adrian Klaver <[email protected]>
Newsgroups gmane.comp.db.postgresql.general
Message-ID <[email protected]>
On 11/22/19 6:32 AM, aleksey ksenzov wrote:
> Hi team.
> Latest time we faced several issues which wouldn't arise provided we 
> have possibility to use constants in foreign key constraints.
> brief example where it would be helpful:
> 
> table_a
> ( id uuid,
> parent_id uuid,
> is_deleted boolean
> )
> having possibility of FK (parent_id, false) to (id, is_deleted)
> would disallow setting parent record deleted flag to true if they have 
> children, or insert record with is_deleted = true parent.

Postgres version?

Look at triggers, in particular CONSTRAINT triggers:

https://www.postgresql.org/docs/12/sql-createtrigger.html

> 
> Regards,
> Aliaksei.


-- 
Adrian Klaver
[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.