From: Adrian Klaver <adrian.klaver@aklaver.com>
To: aleksey ksenzov <alekseyksenzov@gmail.com>
To: pgsql-general@postgresql.org
Subject: Re: Constants in the foreighn key constraints
Date: Fri, 22 Nov 2019 07:25:44 -0800
Message-ID: <85f6184b-cd37-0b7e-9bee-b0d781cead6f@aklaver.com> (raw)
In-Reply-To: <CAB5pSh6Hdw6A6hLAQ+d--6vPzxOs6=Ad4kk5DBei91iirZLNPQ@mail.gmail.com>
References: <CAB5pSh6Hdw6A6hLAQ+d--6vPzxOs6=Ad4kk5DBei91iirZLNPQ@mail.gmail.com>
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
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, alekseyksenzov@gmail.com
Subject: Re: Constants in the foreighn key constraints
In-Reply-To: <85f6184b-cd37-0b7e-9bee-b0d781cead6f@aklaver.com>
References: <CAB5pSh6Hdw6A6hLAQ+d--6vPzxOs6=Ad4kk5DBei91iirZLNPQ@mail.gmail.com> <85f6184b-cd37-0b7e-9bee-b0d781cead6f@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox