From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Achilleas Mantzios <achill@matrix.gatewaynet.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: Exclude constraint on ranges : commutative containment : allow only complete containment
Date: Wed, 29 Jan 2020 10:32:09 -0800
Message-ID: <a1596542-a70f-818e-7f65-280837da31f5@aklaver.com> (raw)
In-Reply-To: <3b555944-1563-6614-a5d5-e0cc001aecdb@matrix.gatewaynet.com>
References: <3b555944-1563-6614-a5d5-e0cc001aecdb@matrix.gatewaynet.com>
On 1/29/20 8:12 AM, Achilleas Mantzios wrote:
> Hello Dear Postgresql ppl,
> I have a table with date ranges and need to express the following
> constraint : allow overlaps only if there is complete containment, e.g.
> allow values in rows like :
> [2020-01-01,2020-01-31)
> [2020-01-02,2020-01-10)
> [2020-01-10,2020-01-20)
>
> but disallow rows like
>
> [2020-01-02,2020-01-10)
> [2020-01-08,2020-01-11)
I'm missing something. Can you provide a more complete example?
>
> I think that writing a new commutative range operator e.g. |<@@> which
> would return true if the left operand is either contained by or contains
> the right operand and false otherwise would solve this, I am just
> wondering if there is a more elegant and economical way to express this.
> (besides writing a trigger which is always an option).|
>
> --
> Achilleas Mantzios
> IT DEV Lead
> IT DEPT
> Dynacom Tankers Mgmt
>
--
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, achill@matrix.gatewaynet.com
Subject: Re: Exclude constraint on ranges : commutative containment : allow only complete containment
In-Reply-To: <a1596542-a70f-818e-7f65-280837da31f5@aklaver.com>
References: <3b555944-1563-6614-a5d5-e0cc001aecdb@matrix.gatewaynet.com> <a1596542-a70f-818e-7f65-280837da31f5@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