Re: [GENERAL] check constraint question

2014-04-08 Thread Alberto Cabello Sánchez
On Tue, 08 Apr 2014 15:53:48 -0600 CS_DBA wrote: > Not sure yet (new client)... for now they simply want to force the > template column to be a valid cust_id, if it is not null... It seems to be a different version of the textbook exercice involving EMPLOYEE_ID and MANAGER_ID. -- Alberto Cabel

Re: [GENERAL] check constraint question

2014-04-08 Thread David Johnston
Based on your first question a customer id itself is not a valid designator; you have to specify (or link) in the group as well. Not tested but should work: FOREIGN KEY (template, group) REFERENCES customer (cust_id, group) Depends on whether you want to allow cross-group associations if you nee

Re: [GENERAL] check constraint question

2014-04-08 Thread CS_DBA
On 04/08/2014 04:08 PM, Rob Sargent wrote: On 04/08/2014 03:53 PM, CS_DBA wrote: On 04/08/2014 03:41 PM, Rob Sargent wrote: On 04/08/2014 03:36 PM, CS_DBA wrote: On 04/08/2014 03:31 PM, Rob Sargent wrote: On 04/08/2014 03:26 PM, CS_DBA wrote: On 04/08/2014 03:17 PM, Rob Sargent wrote: O

Re: [GENERAL] check constraint question

2014-04-08 Thread Rob Sargent
On 04/08/2014 03:53 PM, CS_DBA wrote: On 04/08/2014 03:41 PM, Rob Sargent wrote: On 04/08/2014 03:36 PM, CS_DBA wrote: On 04/08/2014 03:31 PM, Rob Sargent wrote: On 04/08/2014 03:26 PM, CS_DBA wrote: On 04/08/2014 03:17 PM, Rob Sargent wrote: On 04/08/2014 03:09 PM, CS_DBA wrote: On 04/

Re: [GENERAL] check constraint question

2014-04-08 Thread CS_DBA
On 04/08/2014 03:41 PM, Rob Sargent wrote: On 04/08/2014 03:36 PM, CS_DBA wrote: On 04/08/2014 03:31 PM, Rob Sargent wrote: On 04/08/2014 03:26 PM, CS_DBA wrote: On 04/08/2014 03:17 PM, Rob Sargent wrote: On 04/08/2014 03:09 PM, CS_DBA wrote: On 04/08/2014 02:58 PM, Rob Sargent wrote: O

Re: [GENERAL] check constraint question

2014-04-08 Thread Rob Sargent
On 04/08/2014 03:36 PM, CS_DBA wrote: On 04/08/2014 03:31 PM, Rob Sargent wrote: On 04/08/2014 03:26 PM, CS_DBA wrote: On 04/08/2014 03:17 PM, Rob Sargent wrote: On 04/08/2014 03:09 PM, CS_DBA wrote: On 04/08/2014 02:58 PM, Rob Sargent wrote: On 04/08/2014 02:51 PM, CS_DBA wrote: Hi All

Re: [GENERAL] check constraint question

2014-04-08 Thread CS_DBA
On 04/08/2014 03:31 PM, Rob Sargent wrote: On 04/08/2014 03:26 PM, CS_DBA wrote: On 04/08/2014 03:17 PM, Rob Sargent wrote: On 04/08/2014 03:09 PM, CS_DBA wrote: On 04/08/2014 02:58 PM, Rob Sargent wrote: On 04/08/2014 02:51 PM, CS_DBA wrote: Hi All we have a table like so: customer (

Re: [GENERAL] check constraint question

2014-04-08 Thread Rob Sargent
On 04/08/2014 03:26 PM, CS_DBA wrote: On 04/08/2014 03:17 PM, Rob Sargent wrote: On 04/08/2014 03:09 PM, CS_DBA wrote: On 04/08/2014 02:58 PM, Rob Sargent wrote: On 04/08/2014 02:51 PM, CS_DBA wrote: Hi All we have a table like so: customer ( cust_id integer not null

Re: [GENERAL] check constraint question

2014-04-08 Thread CS_DBA
On 04/08/2014 03:17 PM, Rob Sargent wrote: On 04/08/2014 03:09 PM, CS_DBA wrote: On 04/08/2014 02:58 PM, Rob Sargent wrote: On 04/08/2014 02:51 PM, CS_DBA wrote: Hi All we have a table like so: customer ( cust_id integer not null primary key, cust_group_id int

Re: [GENERAL] check constraint question

2014-04-08 Thread Rob Sargent
On 04/08/2014 03:09 PM, CS_DBA wrote: On 04/08/2014 02:58 PM, Rob Sargent wrote: On 04/08/2014 02:51 PM, CS_DBA wrote: Hi All we have a table like so: customer ( cust_id integer not null primary key, cust_group_id integer not null, group_account_idinteger no

Re: [GENERAL] check constraint question

2014-04-08 Thread CS_DBA
On 04/08/2014 02:58 PM, Rob Sargent wrote: On 04/08/2014 02:51 PM, CS_DBA wrote: Hi All we have a table like so: customer ( cust_id integer not null primary key, cust_group_id integer not null, group_account_idinteger not null, cust_name varchar

Re: [GENERAL] check constraint question

2014-04-08 Thread Rob Sargent
On 04/08/2014 02:51 PM, CS_DBA wrote: Hi All we have a table like so: customer ( cust_id integer not null primary key, cust_group_id integer not null, group_account_idinteger not null, cust_name varchar not null, ... ) we want to force the cust_

[GENERAL] check constraint question

2014-04-08 Thread CS_DBA
Hi All we have a table like so: customer ( cust_id integer not null primary key, cust_group_id integer not null, group_account_idinteger not null, cust_name varchar not null, ... ) we want to force the cust_group_id to be unique across all group

Re: [GENERAL] check constraint question

2008-01-25 Thread Gregory Stark
"Tim Rupp" <[EMAIL PROTECTED]> writes: > where start_time >= '2008-01-01'::date AND start_time < '2008-01-10'::date > > should give the same rows as > > where start_time >= '2008-01-01'::date AND end_time <= '2008-01-09'::date I think you'll need to do the same thing to the constraints as well. Y

Re: [GENERAL] check constraint question

2008-01-24 Thread Tim Rupp
On Jan 24, 2008 9:47 AM, Tom Lane <[EMAIL PROTECTED]> wrote: > "Tim Rupp" <[EMAIL PROTECTED]> writes: > > ... a bunch of inherited tables that have the following constraint > > > CHECK (start_time >= '2008-01-01'::date AND end_time < '2008-01-01'::date) > > > and when i do the same query (as in the

Re: [GENERAL] check constraint question

2008-01-24 Thread Tom Lane
"Tim Rupp" <[EMAIL PROTECTED]> writes: > ... a bunch of inherited tables that have the following constraint > CHECK (start_time >= '2008-01-01'::date AND end_time < '2008-01-01'::date) > and when i do the same query (as in the documentation) on the table, I > get a bunch of sequential scans in th

[GENERAL] check constraint question

2008-01-24 Thread Tim Rupp
Hi list, I was looking for a bit of clarification on a check constraint that I have on some tables. I was following the example in the partitioning documentation http://www.postgresql.org/docs/8.2/interactive/ddl-partitioning.html And got it to work, but when I tried to apply the same idea to my