Modeling a join table

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

Modeling a join table

sergio_101
Hello, all.

This question is not as much a question about smalltalk as one about modeling in smalltalk.

I am currently writing an API using Teapot that will be serving up data about internet radio stations. I want to be able to let users tag the stations with arbitrary tags. Using a relational database, I would create an object like "Tagging" with foreign keys pointing to the "Stations" class and the "Tag" Class. It would have station_id and tag_id.

If this was going to be even a tiny bit more complex, I would probably just make it a polymorphic association. 

My question is, how would I approach this in smalltalk? Would I just make methods on tag and station (and whatever else) that stored arrays of each other? Would I create an intermediary model like "Tagging" and have that do the heavy lifting?

Ideas? Thanks!;


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

Public Key: http://bit.ly/29z9fG0
#BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV
http://www.Village-Buzz.com
http://www.ThoseOptimizeGuys.com
http://www.coffee-black.com
http://www.painlessfrugality.com
http://www.twitter.com/sergio_101
http://www.facebook.com/sergio101

signature.asc (852 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Modeling a join table

stepharong
Hi sergio

Did you find a solution to your problem?

Stef

On Tue, 13 Dec 2016 21:59:09 +0100, sergio ruiz <[hidden email]> wrote:

Hello, all.

This question is not as much a question about smalltalk as one about modeling in smalltalk.

I am currently writing an API using Teapot that will be serving up data about internet radio stations. I want to be able to let users tag the stations with arbitrary tags. Using a relational database, I would create an object like "Tagging" with foreign keys pointing to the "Stations" class and the "Tag" Class. It would have station_id and tag_id.

If this was going to be even a tiny bit more complex, I would probably just make it a polymorphic association. 

My question is, how would I approach this in smalltalk? Would I just make methods on tag and station (and whatever else) that stored arrays of each other? Would I create an intermediary model like "Tagging" and have that do the heavy lifting?

Ideas? Thanks!;


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

Public Key: http://bit.ly/29z9fG0
#BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV
http://www.Village-Buzz.com
http://www.ThoseOptimizeGuys.com
http://www.coffee-black.com
http://www.painlessfrugality.com
http://www.twitter.com/sergio_101
http://www.facebook.com/sergio101



--
Using Opera's mail client: http://www.opera.com/mail/
Reply | Threaded
Open this post in threaded view
|

Re: Modeling a join table

Yuriy Mironenko
In reply to this post by sergio_101
Are you going to use relational database to store this data?
Or you goint to use image saving / object-oriented DB for persistence?

Than, can you please describe your task / domain model with more details?
Particularly:
1) Are there strong asymmetry in queries? Which kind of queries are more frequent: "give me tags of this radio" or "give me radios with this tag"?
2) Do you need to store other information EXCEPT fact that that radio is marked by this tag? For example, do you need to store the time tag was assigned to the station or the user who have assigned it? You got the idea, I believe.
3) Are queries simple "stations with tag X" / "tags of station X", or they may often looks like "stations with tag A or B, but not both" or something even more complicated.

Best approach is strongly depends on the answers. "By default", however, I will make Station with collection of Tags as the "main information storage". And I will make some kind of "request" when asked about list of station with some tag. Cache this result, if needed for performance.

But if you plan to use relational persistence backend, than collections on the either side will be the good idea. And you can use GLORP quite easy for this.


2016-12-13 23:59 GMT+03:00 sergio ruiz <[hidden email]>:
Hello, all.

This question is not as much a question about smalltalk as one about modeling in smalltalk.

I am currently writing an API using Teapot that will be serving up data about internet radio stations. I want to be able to let users tag the stations with arbitrary tags. Using a relational database, I would create an object like "Tagging" with foreign keys pointing to the "Stations" class and the "Tag" Class. It would have station_id and tag_id.

If this was going to be even a tiny bit more complex, I would probably just make it a polymorphic association. 

My question is, how would I approach this in smalltalk? Would I just make methods on tag and station (and whatever else) that stored arrays of each other? Would I create an intermediary model like "Tagging" and have that do the heavy lifting?

Ideas? Thanks!;



Reply | Threaded
Open this post in threaded view
|

Re: Modeling a join table

sergio_101

Are you going to use relational database to store this data?
Or you goint to use image saving / object-oriented DB for persistence?


i’d like to use voyage.. so i can use MongoDB for persistence..



1) Are there strong asymmetry in queries? Which kind of queries are more frequent: "give me tags of this radio" or "give me radios with this tag"?

i would say that at the end of the day, it is going to be about the same.. lots and lots of each call..


2) Do you need to store other information EXCEPT fact that that radio is marked by this tag? For example, do you need to store the time tag was assigned to the station or the user who have assigned it? You got the idea, I believe.

i am going to guess that there will be more information on this.. as in.. who created the tag..

so i can import JUST that user’s tags for their list.. while maintaining a set of tags as default tags..


3) Are queries simple "stations with tag X" / "tags of station X", or they may often looks like "stations with tag A or B, but not both" or something even more complicated.


queries will simply be.. give me all stations with this tag..  or these tags..


thanks!

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

Public Key: http://bit.ly/29z9fG0
#BitMessage BM-NBaswViL21xqgg9STRJjaJaUoyiNe2dV
http://www.Village-Buzz.com
http://www.ThoseOptimizeGuys.com
http://www.coffee-black.com
http://www.painlessfrugality.com
http://www.twitter.com/sergio_101
http://www.facebook.com/sergio101

signature.asc (852 bytes) Download Attachment