Skip site navigation (1) Skip section navigation (2)

Re: special integrity constraints

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Erik Thiele <erik(at)thiele-hydraulik(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: special integrity constraints
Date: 2004-03-22 11:26:04
Message-ID: 20040322112604.GA31222@wolff.to (view raw or flat)
Thread:
Lists: pgsql-docspgsql-sql
On Mon, Mar 22, 2004 at 10:20:31 +0100,
  Erik Thiele <erik(at)thiele-hydraulik(dot)de> wrote:
> hi,
> 
> i have two tables
> 
> create table a (x integer);
> create table b (y real);
> 
> i have the special constraint that the sum of the number of rows in
> table a plus the number of rows in table b must be even.

Does the above mean that the number of rows in a is equal to the number
of rows in b or that their sum is divisible by 2?

> so there is a posibility of adding one element to a and one element to
> b, and again the constraint is met.
> 
> but this of course does not work, since between adding the element to a
> and adding the element to b, the constraint is not met.
> 
> so i cannot use a trigger.
> 
> what i need is the execution of a check procedure at commit time. is
> that somehow possible?

Do the real tables have candidate keys? If so you can use foreign key
references to pair a row in a to a row b (though I am not sure this
is what your real constraint is).

In response to

Responses

pgsql-docs by date

Next:From: Achilleus MantziosDate: 2004-03-22 11:40:11
Subject: Re: special integrity constraints
Previous:From: Erik ThieleDate: 2004-03-22 10:26:59
Subject: Re: special integrity constraints

pgsql-sql by date

Next:From: Martin MarquesDate: 2004-03-22 11:32:32
Subject: Re: inverse of "day of year"
Previous:From: Erik ThieleDate: 2004-03-22 10:26:59
Subject: Re: special integrity constraints

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group