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

Re: Composite UNIQUE across two tables?

From: "Jamie Tufnell" <diesql(at)googlemail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: Composite UNIQUE across two tables?
Date: 2008-03-07 16:09:08
Message-ID: b0a4f3350803070809x9da3b74oeaa20a75c2d14936@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-sql
Hi Jorge,

On 3/7/08, Jorge Godoy <jgodoy(at)gmail(dot)com> wrote:
> Em Thursday 06 March 2008 22:10:14 Jamie Tufnell escreveu:
> > I'm not sure how I would enforce that the site_group_id
> > added to the users table would correspond correctly with
> > the site_id (as per the sites table).  Perhaps I would make a
> > composite foreign key?
>
> Or you manage site_group_id from a trigger. When the user creates / chooses
> a site_id and updates/inserts this information then you fill site_group_id
> with a trigger. This way you guarantee the correctness of this parameter.

Hmm.  So your advice would be to duplicate the
site_group_id field into the users table as well?

That looks to be the consensus.. so I'm not sure why it feels
like I'm doing something wrong :-)

Thanks for your input!

J.

In response to

pgsql-sql by date

Next:From: Markus SchattenDate: 2008-03-08 01:12:55
Subject: plpythonu + os.spawnv
Previous:From: Jamie TufnellDate: 2008-03-07 15:46:53
Subject: Re: Composite UNIQUE across two tables?

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