Re: [GENERAL] unique index for periods

2009-08-20 Thread Jeff Davis
On Thu, 2009-08-20 at 13:35 +0200, Harald Fuchs wrote: > Have a look at http://pgfoundry.org/projects/temporal The temporal project on pgfoundry only provides the time period type, which is (hopefully) useful, but it does not help with a non-overlapping constraint. Please see my other project her

Re: [GENERAL] unique index for periods

2009-08-20 Thread Tom Lane
Greg Stark writes: > On Thu, Aug 20, 2009 at 3:14 PM, Tom Lane wrote: >> I don't believe it is possible to use a btree index for this purpose, >> because there just isn't a way to express "overlaps" as a total order. > That's true for the general case of indexing ranges but I don't think > that's

Re: [GENERAL] unique index for periods

2009-08-20 Thread Greg Stark
On Thu, Aug 20, 2009 at 3:14 PM, Tom Lane wrote: > I don't believe it is possible to use a btree index for this purpose, > because there just isn't a way to express "overlaps" as a total order. That's true for the general case of indexing ranges but I don't think that's true for the case where ove

Re: [GENERAL] unique index for periods

2009-08-20 Thread Tom Lane
Gerhard Heift writes: > I try to create an unique index for a (time)period, and my goal is to > prevent two overlapping periods in a row. > To use the btree index I added a compare function: >return > CASE > WHEN $1.next <= $2.first THEN -1 > WHEN $2.next <= $1.first

Re: [GENERAL] unique index for periods

2009-08-20 Thread Harald Fuchs
In article <20090820065819.ga2...@gheift.kawo1.rwth-aachen.de>, Gerhard Heift writes: > Hello, > I try to create an unique index for a (time)period, and my goal is to > prevent two overlapping periods in a row. > ... > Is there another solution to solve my problem? Have a look at http://pgfoun