pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: A. Kretschmer <akretschmer@despammed.com>
To: pgsql-sql@postgresql.org
Subject: Re: diary constraints
Date: Tue, 23 Aug 2005 11:12:38 +0200
Message-ID: <20050823091238.GD24431@webserv.wug-glas.de> (raw)
In-Reply-To: <200508230933.59043.gary.stainburn@ringways.co.uk>
References: <200508230933.59043.gary.stainburn@ringways.co.uk>

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    === 



view thread (6+ messages)

Message-ID: <20050823091238.GD24431@webserv.wug-glas.de>
Permalink:  ../20050823091238.GD24431@webserv.wug-glas.de/
Also on:    postgresql.org/message-id/20050823091238.GD24431@webserv.wug-glas.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: akretschmer@despammed.com
  Subject: Re: diary constraints
  In-Reply-To: <20050823091238.GD24431@webserv.wug-glas.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox