Re: sub query constraint

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Dale Sykora <dalen(at)czexan(dot)net>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: sub query constraint
Date: 2005-03-29 04:15:20
Message-ID: 20050329041520.GA4277@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Mon, Mar 28, 2005 at 16:13:59 -0600,
Dale Sykora <dalen(at)czexan(dot)net> wrote:
>
> CREATE TABLE user_data(
> name varchar(32),
> write_access bool DEFAULT 'f'
> );
> CREATE TABLE actions(
> action varchar(32),
> user varchar(32) -- somehow make sure user = user_data.name where
> user_data.write_access = 't'
> );

One way to do this is to add a write_access column to actions and use
a constraint to force it to be true. Create a UNIQUE key of
(name, write_access) for user_data and then add a FOREIGN KEY
reference from (name, write_access) in actions to (name, write_access)
in user_data.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Yudie Pg 2005-03-29 04:37:42 Re: sub query constraint
Previous Message Christopher Browne 2005-03-29 02:42:23 Re: Linux Filesystem for PG