views:

35

answers:

1

Just looking for some advice on how to structure my relationships in an app that I'm making. I have the following models:

activity # golf, karaoke
event    # golf competition followed by all-night karaoke boat party
post     # write-up of the golf and karaoke event mentioned above
gallery  # photos from the golf and karaoke event

Question 1

  • each event can involve more than one activity
  • each activity can be associated with more than one event

Do I need a habtm between activity and event?


Question 2

  • each event can be reported in more than one blog post
  • a post can report on more than one event

Should I use a habtm between event and post?


Question 3

  • each post can include images from more than one gallery
  • a gallery can be included in more than one post

Is this another habtm?


Question 4 - It's conceivable that the admins might want to link 1 or more sets of photos with 1 or more events, without creating a blog post to tie everything together. Would it be advisable to declare a habtm relationship between galleries and events?


For bonus points: Is an app with this many habtm's likely to be slower than one which enforces one-to-many relationships between the same models? Is there a suggested limit to the number of habtm relationships an app an have before it becomes too complex?

Thanks in advance

+1  A: 

All cases needs habtm. It follows from your specyfication. You can only wonder if you really need such relations. Look at http://en.wikipedia.org/wiki/You_ain%27t_gonna_need_it "YAGNI". I would not also think about speed during developement. When your app will be slow, add caching.

Sławosz
thanks for the advice! nice link too..
stephenmurdoch