Received: from magus.postgresql.org (magus.postgresql.org [87.238.57.229]) by mail.postgresql.org (Postfix) with ESMTP id A942614E1F38 for ; Thu, 2 Aug 2012 20:11:03 -0300 (ADT) Received: from eastrmfepo202.cox.net ([68.230.241.217]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1Sx4Xj-0003Ee-Dz for pgsql-sql@postgresql.org; Thu, 02 Aug 2012 23:11:02 +0000 Received: from eastrmimpo210.cox.net ([68.230.241.225]) by eastrmfepo202.cox.net (InterMail vM.8.01.04.00 201-2260-137-20101110) with ESMTP id <20120802231044.WGVP1165.eastrmfepo202.cox.net@eastrmimpo210.cox.net> for ; Thu, 2 Aug 2012 19:10:44 -0400 Received: from slacker.ja10629.home ([68.106.109.147]) by eastrmimpo210.cox.net with bizsmtp id hzAj1j00S3Ar1Vg02zAk3U; Thu, 02 Aug 2012 19:10:44 -0400 X-CT-Class: Clean X-CT-Score: 0.00 X-CT-RefID: str=0001.0A020201.501B08F4.0078,ss=1,re=0.000,fgs=0 X-CT-Spam: 0 X-Authority-Analysis: v=1.1 cv=V/oGLRJUwA6r8g3YRpt7G9k8adX+08FyA6GagTg0h7E= c=1 sm=1 a=z1TLwsU0kBEA:10 a=F087GG655-4A:10 a=PjkiJtDTOQ4A:10 a=ZcFhQy0-F_sA:10 a=kj9zAlcOel0A:10 a=sXZhTwfwSKhiTs9RzZXpNQ==:17 a=yJ9a2ciSyRj_MfZeoacA:9 a=CjuIK1q_8ugA:10 a=sXZhTwfwSKhiTs9RzZXpNQ==:117 X-CM-Score: 0.00 Authentication-Results: cox.net; none Received: from wcuddy by slacker.ja10629.home with local (Exim 4.72) (envelope-from ) id 1Sx4XT-0004EF-Oy for pgsql-sql@postgresql.org; Thu, 02 Aug 2012 19:10:43 -0400 Date: Thu, 2 Aug 2012 19:10:43 -0400 From: Wayne Cuddy To: PostgreSQL Subject: can this be done with a check expression? Message-ID: <20120802231043.GA16173@slacker.ja10629.home> Mail-Followup-To: PostgreSQL Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.4.2.3i X-Pg-Spam-Score: -0.0 (/) X-Archive-Number: 201208/2 X-Sequence-Number: 36773 I have a table with 3 columns: name text start_id integer end_id integer start_id and end_id are ranges which must not overlap but can have gaps between them. Is it possible to formulate a table check constraint that can verify that either id does not fall within an existing range at insert time? IE prevent overlaps during insert? Thanks, Wayne