simulating has and belongs to many (HABTM)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

simulating has and belongs to many (HABTM)

sergio_101
i just want to make sure that i am thinking about this the
seaside/smalltalk way..

i would like to build a 'has and belongs to many' relation where i can
drill down on my data from either side.

say i have a movie, and a theater. a movie can be shown in many
theaters, and a theater can show many movies.

i would want to be able to ask a theater what movies it's showing, or
a movie which theaters it is showing in.

my initial thought would be to create a 'showing' model, where  it
would have a movie and a theater attached.. then i could query showing
for either movie or theater..

or, i could have a theaters Collection on movies and a movies
Collection on on theaters, and contain that information in only two
models..

any suggestions?

thanks!

--
----
peace,
sergio
photographer, journalist, visionary

http://www.ThoseOptimizeGuys.com
http://www.CodingForHire.com
http://www.coffee-black.com
http://www.painlessfrugality.com
http://www.twitter.com/sergio_101
http://www.facebook.com/sergio101

Reply | Threaded
Open this post in threaded view
|

Re: simulating has and belongs to many (HABTM)

Stéphane Ducasse

On Sep 27, 2012, at 8:29 PM, sergio_101 wrote:

> i just want to make sure that i am thinking about this the
> seaside/smalltalk way..
>
> i would like to build a 'has and belongs to many' relation where i can
> drill down on my data from either side.
>
> say i have a movie, and a theater. a movie can be shown in many
> theaters, and a theater can show many movies.
>
> i would want to be able to ask a theater what movies it's showing, or
> a movie which theaters it is showing in.
>
> my initial thought would be to create a 'showing' model, where  it
> would have a movie and a theater attached.. then i could query showing
> for either movie or theater..

I would say that it depend is the showing is an important part of your domain.
Else you can either have dictionaries or collections on both movie and theater.

>
> or, i could have a theaters Collection on movies and a movies
> Collection on on theaters, and contain that information in only two
> models..
>
> any suggestions?
>
> thanks!
>
> --
> ----
> peace,
> sergio
> photographer, journalist, visionary
>
> http://www.ThoseOptimizeGuys.com
> http://www.CodingForHire.com
> http://www.coffee-black.com
> http://www.painlessfrugality.com
> http://www.twitter.com/sergio_101
> http://www.facebook.com/sergio101
>


Reply | Threaded
Open this post in threaded view
|

Re: simulating has and belongs to many (HABTM)

sergio_101
> I would say that it depend is the showing is an important part of your domain.
> Else you can either have dictionaries or collections on both movie and theater.

so, either way, i am not breaking any best practices?

--
----
peace,
sergio
photographer, journalist, visionary

http://www.ThoseOptimizeGuys.com
http://www.CodingForHire.com
http://www.coffee-black.com
http://www.painlessfrugality.com
http://www.twitter.com/sergio_101
http://www.facebook.com/sergio101

Reply | Threaded
Open this post in threaded view
|

Re: simulating has and belongs to many (HABTM)

Esteban A. Maringolo
sergio_101 wrote
> I would say that it depend is the showing is an important part of your domain.
> Else you can either have dictionaries or collections on both movie and theater.

so, either way, i am not breaking any best practices?
A Theather will probably have many MovieShow's, which will have in which room it will be shown, the showtime, and the actual movie title, which may be the same but with variants (translated, subtitled, 3D, imax, or those combined), you could also reify the combinations based on language, subtitles (lang, or none), etc.

And this is an overly simplified analysis of a domain I barely know.

Magritte provides descriptions for these relations, and will create editors based on such relations.
I don't know if there is any Magritte-Glorp integration to manage that.

Regards!

--
Esteban