Re: Unique Keys

From: Jonathan Leffler <jleffler_at_earthlink.net>
Date: Thu, 25 Nov 2004 04:57:25 GMT
Message-ID: <VCdpd.3335$NU3.1751_at_newsread1.news.pas.earthlink.net>


Kenneth Downs wrote:
> Continuing the debate on unique keys. Can anything at all be converted to a
> unique key? What about this one:
>
> CREATE TABLE reservations (
> hotel_room char(4),
> date_start date,
> date_end date )
>
> which requires a constraint that no two reservations can overlap.[...]

As Mikito already said, the pair of dates constitute an interval, and there are special operators required for handling intervals. See Date, Darwen and Lorentzos "Temporal Data and the Relational Model" or Snodgrass "Developing Time-Oriented Database Applications in SQL" (which is out of print but available in PDF from http://www.cs.arizona.edu/people/rts/). Both are tough going in patches.

-- 
Jonathan Leffler                   #include <disclaimer.h>
Email: jleffler_at_earthlink.net, jleffler_at_us.ibm.com
Guardian of DBD::Informix v2003.04 -- http://dbi.perl.org/
Received on Thu Nov 25 2004 - 05:57:25 CET

Original text of this message