Re: diary constraints - Mailing list pgsql-sql

From A. Kretschmer
Subject Re: diary constraints
Date
Msg-id 20050823091238.GD24431@webserv.wug-glas.de
Whole thread Raw
In response to diary constraints  (Gary Stainburn <gary.stainburn@ringways.co.uk>)
List pgsql-sql
am  23.08.2005, um  9:33:58 +0100 mailte Gary Stainburn folgendes:
> Hi folks
> 
> I know this has been discussed in the past, but no amount of keywords 
> has returned anything from the archives.
> 
> I want to create a courtesy car diary diary system where I have a table 
> containing all of the cortesy cars in the pool, and then an allocation 
> table which has two timestamps, one for the start date/time and one for 
> the return date/time.
> 
> How do I go about creating constraints on inserts and updates to ensure 
> that
> 
> a) the finish is after the start

with a check-constraint like this:
create table foobar (t1 timestamp, t2 timestamp check (t2>t1));


> b) two allocations for a single vehicle don't overlap.

possibly with a trigger.


Regards, Andreas
-- 
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47212,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net===    Schollglas Unternehmensgruppe    === 


pgsql-sql by date:

Previous
From: PFC
Date:
Subject: Re: diary constraints
Next
From:
Date:
Subject: Re: Problem calling stored procedure