Re: Clues on modeling a really simple concept
Date: Mon, 6 Apr 2009 14:00:21 -0700 (PDT)
On Apr 6, 1:01 pm, Spike <fau..._at_gmail.com> wrote:
> Hi everybody!
> I'm trying to model a photo gallery, and i have a doubt on how to
> implement it.
> I have a table for users. I have another table for pictures. And
> finally, i have a table for galleries (which are sets of pictures).
> Both galleries and pictures belongs to a single user, but a single
> picture can be used on many galleries.
> So, i have something like this:
> users --> pictures --> pictures_to_galleries --> galleries
> My question is: Should i add a relationship between galleries and
> I would like to query which galleries a user has, and i don't really
> know if it is worth adding a foreign key rather than doing a three-
> level join query each time i want to obtain this data.
> Thank you very much!
Based on what you've written, I think I'd model this as U -->> P (1:M) , U -->> G (1:M), and P <<-->> G (M:N), with the latter resolved as P -->> PG <<-- G. So, yes--you could get at the galleries through the pictures, but what you're ultimately saying is that users create galleries to assign pictures that they own to.
--Jeff Received on Mon Apr 06 2009 - 23:00:21 CEST