[Dbix-class] many_to_many data access
Patrick Meidl
patrick at pantheon.at
Thu Jul 12 09:41:12 GMT 2012
On Thu, Jul 12 2012, Frank Schwach <fs5 at sanger.ac.uk> wrote:
nice to see a "colleague" from one of my former employers on this thread
;-)
> On 12/07/12 09:29, Patrick Meidl wrote:
> >On Thu, Jul 12 2012, Robyn Jonahs<learn.catalyst at gmail.com> wrote:
> >
> >>The cities, states and country relationships are all many_to_many so
> >>once I have one, I can do the others.
> >as I mentioned before, in terms of a clean database design, shouln't
> >your relationships look like this: City belongs_to a State, which in
> >turn belongs_to a Country. having city, state and country as independent
> >many_to_many on the store violates the true relationships between these
> >entities.
>
> except if you are expecting international customers: in many countries
> there are no "states", so a city really only "might_have" a state and
> the city itself "belongs_to" a country, The (optional) state also
> "belongs_to" a country adn there is no need to establish the link
> between cities and states at all
you are right of course, and now that I think about it again I remember
that I implemented it like that myself in a previous project.
nevertheless, I still think that the State and Country relations should
at least be on the City, not the Store, as the OP indicated.
> not to mention the problem you might have in some countries where
> cities can even belong to more than one province.
I decided to ignore this special case so far :)
patrick
--
Patrick Meidl ........................ patrick at pantheon.at
Vienna, Austria ...................... http://gplus.to/pmeidl
More information about the DBIx-Class
mailing list