Re: challenging constraint situation - how do I make it - Mailing list pgsql-general

From Alban Hertroys
Subject Re: challenging constraint situation - how do I make it
Date
Msg-id 44741EC4.9010506@magproductions.nl
Whole thread Raw
In response to challenging constraint situation - how do I make it real in SQL?  ("Harald Armin Massa" <haraldarminmassa@gmail.com>)
Responses Re: challenging constraint situation - how do I make it  (Kenneth Downs <ken@secdat.com>)
List pgsql-general
Harald Armin Massa wrote:
> I have a business rule which gives me rahter big challenges to "melt in
> SQL":

> But it is not really fitting; and manual editing of the table can
> disturb it. So, ist there some constraint creatable to make sure that
> "in each point of time" each id only exists once?

You probably need to write a constraint trigger, using OVERLAPS and
EXISTS operators. Writing one is rather trivial, but depends on your
exact business rules.

 From your example it is not clear to me if you can have, for example,
two records with different id's within the same or overlapping timespans.

When encountering this problem I usually wonder why there isn't a data
type that can store a timestamp and can be used to create a UNIQUE INDEX
over it's values. That'd be wonderful.
Well, maybe one day I'll actually have time to create one...

--
Alban Hertroys
alban@magproductions.nl

magproductions b.v.

T: ++31(0)534346874
F: ++31(0)534346876
M:
I: www.magproductions.nl
A: Postbus 416
    7500 AK Enschede

// Integrate Your World //

pgsql-general by date:

Previous
From: sibel karaasma
Date:
Subject: compiling source code!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Next
From: Alban Hertroys
Date:
Subject: Re: [SQL] (Ab)Using schemas and inheritance