Re: Composite UNIQUE across two tables? - Mailing list pgsql-sql

From Jamie Tufnell
Subject Re: Composite UNIQUE across two tables?
Date
Msg-id b0a4f3350803061710y2d3391cdwa54d7dcf4af5692f@mail.gmail.com
Whole thread Raw
In response to Composite UNIQUE across two tables?  ("Jamie Tufnell" <diesql@googlemail.com>)
Responses Re: Composite UNIQUE across two tables?  (Jorge Godoy <jgodoy@gmail.com>)
List pgsql-sql
Hi Ray,

Thanks for your reply!

On 3/6/08, Ray Madigan <ray@madigans.org> wrote:
> I don't think I understand. You have a constraint that a user has implied
> access to any site in the group, explain why you think it would be wrong to
> have the group_id as an instance variable fro the user. Otherwise whenever
> the user is in a site in the site group other then the specific site
> represented by the user.site_id the query has to go join with the site to
> find the site group.

That's true.  I'll try to explain why it feels wrong...

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?

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.

Cheers,
J.


pgsql-sql by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: query results in XML format?
Next
From: Jorge Godoy
Date:
Subject: Re: Composite UNIQUE across two tables?