Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search for
  Advanced Search

Re: challenging constraint situation - how do I make it


  • From: Alban Hertroys <alban(at)magproductions(dot)nl>
  • To: Harald Armin Massa <haraldarminmassa(at)gmail(dot)com>
  • Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
  • Subject: Re: challenging constraint situation - how do I make it
  • Date: Wed, 24 May 2006 10:52:20 +0200
  • Message-id: <44741EC4(dot)9010506(at)magproductions(dot)nl>

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(at)magproductions(dot)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 //



Home | Main Index | Thread Index

Privacy Policy | PostgreSQL Archives hosted by Command Prompt, Inc. | Designed by tinysofa
Copyright © 1996 – 2008 PostgreSQL Global Development Group