pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jamie Tufnell <diesql@googlemail.com>
To: pgsql-sql@postgresql.org
Subject: Re: Composite UNIQUE across two tables?
Date: Fri, 7 Mar 2008 16:09:08 +0000
Message-ID: <b0a4f3350803070809x9da3b74oeaa20a75c2d14936@mail.gmail.com> (raw)
In-Reply-To: <200803062322.27911.jgodoy@gmail.com>
References: <b0a4f3350803061104s89656bcl739e1aa1cdcb6e3a@mail.gmail.com>
	<CMEFJOLLJJDJKKLGEJJMGEJDCAAA.ray@madigans.org>
	<b0a4f3350803061710y2d3391cdwa54d7dcf4af5692f@mail.gmail.com>
	<200803062322.27911.jgodoy@gmail.com>

Hi Jorge,

On 3/7/08, Jorge Godoy <jgodoy@gmail.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.



view thread (14+ messages)  latest in thread

Message-ID: <b0a4f3350803070809x9da3b74oeaa20a75c2d14936@mail.gmail.com>
Permalink:  ../b0a4f3350803070809x9da3b74oeaa20a75c2d14936@mail.gmail.com/
Also on:    postgresql.org/message-id/b0a4f3350803070809x9da3b74oeaa20a75c2d14936@mail.gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: diesql@googlemail.com
  Subject: Re: Composite UNIQUE across two tables?
  In-Reply-To: <b0a4f3350803070809x9da3b74oeaa20a75c2d14936@mail.gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox