Received: from localhost (unknown [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 95E442E01D2 for ; Fri, 7 Mar 2008 12:09:19 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 45938-02 for ; Fri, 7 Mar 2008 12:09:10 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from fg-out-1718.google.com (fg-out-1718.google.com [72.14.220.154]) by postgresql.org (Postfix) with ESMTP id DB7362E017F for ; Fri, 7 Mar 2008 12:09:09 -0400 (AST) Received: by fg-out-1718.google.com with SMTP id 22so426074fge.23 for ; Fri, 07 Mar 2008 08:09:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=5rMxbRkEaf+elfN7ZlvjQN+Gvf/+Ljflc8jy9svGwEk=; b=sNHsqNWOc+cgteSTm224+37jilHSRFGAXuy6TKPX+60WPjfLLsErnMZhFx9LYu2SAVeZ5rvXP0lvyrrfXzv4zmDGnQxH5AooeFak6tZbKGmdSWCKIUeasepg5riVXeaR0VqWx+SHjfH5x3FjBm5mIjYnUVIxSy4+exdI9ETvHRE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=b3YDlaV+7dhKGK9IeE7sihxVcDBLqKGwBWYx4vx0TW+ElGYf/PsQduf25SsrpMq3GD7DrDpRXSCDZDyUZJiHWQHmSGzgrc2uNmlPv0YM4r79dFEZAjbUZYl/qQBfodSD2XnuCv1tgw7u1kDsB37Ms3sgGYQY+rGAIZhi1+LAV1Q= Received: by 10.86.3.4 with SMTP id 4mr1646695fgc.55.1204906148978; Fri, 07 Mar 2008 08:09:08 -0800 (PST) Received: by 10.86.86.18 with HTTP; Fri, 7 Mar 2008 08:09:08 -0800 (PST) Message-ID: Date: Fri, 7 Mar 2008 16:09:08 +0000 From: "Jamie Tufnell" To: pgsql-sql@postgresql.org Subject: Re: Composite UNIQUE across two tables? In-Reply-To: <200803062322.27911.jgodoy@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <200803062322.27911.jgodoy@gmail.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200803/45 X-Sequence-Number: 30373 Hi Jorge, On 3/7/08, Jorge Godoy 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.