X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 8E15BD7094 for ; Tue, 23 Aug 2005 05:58:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 69527-04 for ; Tue, 23 Aug 2005 08:58:17 +0000 (GMT) Received: from smtp-send.myrealbox.com (smtp-send.myrealbox.com [192.108.102.143]) by svr1.postgresql.org (Postfix) with ESMTP id E4750D7071 for ; Tue, 23 Aug 2005 05:58:16 -0300 (ADT) Received: from [172.16.1.182] grzm [61.197.227.146] by smtp-send.myrealbox.com with NetMail SMTP Agent $Revision: 1.6 $ on Linux via secured & encrypted transport (TLS); Tue, 23 Aug 2005 02:58:17 -0600 In-Reply-To: <200508230933.59043.gary.stainburn@ringways.co.uk> References: <200508230933.59043.gary.stainburn@ringways.co.uk> Mime-Version: 1.0 (Apple Message framework v734) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <55E1EB3D-E2CF-41FD-86AD-B39007A48BF9@myrealbox.com> Cc: postgresql sql list Content-Transfer-Encoding: 7bit From: Michael Glaesemann Subject: Re: diary constraints Date: Tue, 23 Aug 2005 17:58:13 +0900 To: Gary Stainburn X-Mailer: Apple Mail (2.734) X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.029 required=5 tests=[AWL=0.029] X-Spam-Level: X-Archive-Number: 200508/199 X-Sequence-Number: 22427 On Aug 23, 2005, at 5:33 PM, Gary Stainburn wrote: > 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 > b) two allocations for a single vehicle don't overlap. This is an interesting problem. You might want to take a look at this book, previously mentioned on the one of the lists (by George Essig, I believe): > Developing Time-Oriented Database Applications in SQL > by Richard T. Snodgrass > > The book is out of print, but the author has made the PDF available > on his website at: > http://www.cs.arizona.edu/people/rts/tdbbook.pdf Hope this helps! Michael Glaesemann grzm myrealbox com