Subject Checking periods don't overlap
Author johnsparrowuk
Any idea how to check periods don't overlap?? Ie in a table:

create table T (entryid integer not null primary key, startdate
timestamp not null, enddate timestamp not null);

I could have a trigger like this:

/* Before insert / update trigger */
if (exists(select entryid from T where not(T.startdate > new.enddate
or T.enddate < new.startdate) and T.entryid <> new.entryid)) then
begin
exception dates_overlap 'Your dates overlap';
end


But hey-ho, I can't dirty-read so it doesn't work properly!!!

Come on guys, am I the only one who finds this a bit of a problem??

If it would be *extremely difficult* to implement, say so, and
that's fare enough. I just don't see how no one else finds it a
deficiency.

Using indexes to dirty-read and act as consistency constraints just
isn't flexible enough for things like this. And, arguably, it's not
what indexes should be about anyway...

John