Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 37BE12E015C for ; Thu, 6 Mar 2008 22:22:40 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 72101-01 for ; Thu, 6 Mar 2008 22:22:37 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.5 Received: from an-out-0708.google.com (an-out-0708.google.com [209.85.132.250]) by postgresql.org (Postfix) with ESMTP id 8CA482E0167 for ; Thu, 6 Mar 2008 22:22:37 -0400 (AST) Received: by an-out-0708.google.com with SMTP id c36so66940ana.33 for ; Thu, 06 Mar 2008 18:22:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:received:x-virus-scanned:received:received:received:from:to:subject:date:user-agent:references:in-reply-to:x-face:mime-version:content-type:content-transfer-encoding:content-disposition:message-id; bh=XdtXwxCgqqTs8MKD3rG3zCtHefvWu8sFiad0GyB7zXQ=; b=JwKlt5++UiAyJHSQ/vpf/9+BeocjU6O8xIjtat22apMcozyaNZwkUbBmYYXbRUr0fKIMtLvp1NtF1UQDd7PS2qAgC5tDYBYl6Hj5a4jWgwiwcxulhvybC3FEMYf7bwsffTL0Fa6he/Mm84giaKDKjLuEubIBu7PpI6xcjhpoamc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=x-virus-scanned:from:to:subject:date:user-agent:references:in-reply-to:x-face:mime-version:content-type:content-transfer-encoding:content-disposition:message-id; b=j5AJ43JEc47mQ6rMZy7OLr9Z2aG+W+28SAtd4rO3dscY1vjcQCHrTnCBtTewKSA/ZBR1KzUpLGTxZ8lwnctoavzwY6iibtFdrWIPTUZHClO4lTUSub/YKjIg0n2CeK2TK3BdVD6FSYFjy9S6BBwdXLg+nn2pos71+YDmm9tZQqk= Received: by 10.100.4.1 with SMTP id 1mr1433254and.98.1204856556281; Thu, 06 Mar 2008 18:22:36 -0800 (PST) Received: from strongwill.g2ctech ( [189.26.15.175]) by mx.google.com with ESMTPS id 34sm4993999agc.32.2008.03.06.18.22.33 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 06 Mar 2008 18:22:35 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by strongwill.g2ctech (Postfix) with ESMTP id 5A5DD10F22C for ; Thu, 6 Mar 2008 23:22:08 -0300 (BRT) X-Virus-Scanned: amavisd-new at g2ctech.com Received: from strongwill.g2ctech ([127.0.0.1]) by localhost (strongwill.g2ctech [127.0.0.1]) (amavisd-new, port 10024) with LMTP id wTEdV1oFSACd for ; Thu, 6 Mar 2008 23:22:07 -0300 (BRT) Received: from revolution.g2ctech (unknown [10.0.0.142]) by strongwill.g2ctech (Postfix) with ESMTP id 927B810EEF2 for ; Thu, 6 Mar 2008 23:22:07 -0300 (BRT) Received: from localhost (localhost [127.0.0.1]) by revolution.g2ctech (Postfix) with ESMTP id DEE3A1E316E for ; Thu, 6 Mar 2008 23:22:28 -0300 (BRT) From: Jorge Godoy To: pgsql-sql@postgresql.org Subject: Re: Composite UNIQUE across two tables? Date: Thu, 6 Mar 2008 23:22:27 -0300 User-Agent: KMail/1.9.9 References: In-Reply-To: X-Face: M#4Raj:HA%$5G'U'r/n!6t/k++cCj}FAP#Uw=7]=; wT0mlqR\jeUgAbq\f(\Kx7Fqol!<@=?utf-8?q?=0A=09IQoR63z5P=5Fz8-Bn?=){[YIi(\qmoww[hv~rrM^:tp=_T4QGF0p`zMbk@=?utf-8?q?OEuGEIuL3/zW=5B5eL=0A=09ME=5D4drosu=7CA=27=3DHvnQqJjFGce=7DXu?=)$F2C$/P.xxqb\n]!w07-8@u4GT"G9Cy1l$4TEdx@=?utf-8?q?=5Fq=0A=09M=7E=7E*Uek=2E?= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200803/36 X-Sequence-Number: 30364 Em Thursday 06 March 2008 22:10:14 Jamie Tufnell escreveu: > > I already have site_id in the users table and I can determine the > site_group_id from that. So it seems redundant to me, to store > site_group_id for each user as well. Also, 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. > I've never come up against this situation before, and because of the > reasons above, I'm getting the feeling there might be a better way to > design this. Again, a trigger can do that. Slower than denormalizing the database, but it can be done. -- Jorge Godoy