SQL CHECK constraint to prevent date overlap

Posted by Michael on Stack Overflow See other posts from Stack Overflow or by Michael
Published on 2010-03-19T11:00:44Z Indexed on 2010/03/19 11:01 UTC
Read the original article Hit count: 352

Filed under:
|
|
|

I have a table that describes which software versions were installed on a machine at various times:

machine_id::integer, version::text, datefrom::timestamp, dateto::timestamp

I'd like to do a constraint to ensure that no date ranges overlap, i.e. it is not possible to have multiple software versions installed on a machine at the same time.

How can this be achieved in SQL? I am using PostgreSQL v8.4.

© Stack Overflow or respective owner

Related posts about sql

Related posts about constraints