2009/6/28 Marnen Laibow-Koser <[email protected]>:
>
> Grayson Piercee wrote:
>> Hello,
>>
>> I'm writing a Rails application that will track people's interests.  I'd
>> like to keep detailed information about each type of interest so I can't
>> just put everything in the interest table (the table would be just too
>> wide)
>
> There is absolutely nothing wrong with a wide table if that's the best
> way to model your data.  Don't discard a design based on number of
> fields alone.
>
>>
>> User
>>   has_many :interests
>>
>> Interest
>>   belongs_to :user
>>   has_many   :sports
>>   has_many   :books
>>   has_many   :tv_shows
>>   etc., etc.
>
> How can an Interest have many Sports?  If you think about your naming
> scheme, you'll see that it's telling you that a Sport *is* an Interest.
> So make Interest an abstract class (with subclasses Sport, Book, and
> TvShow), then either use STI or a polymorphic association to link each
> Interest subclass directly to User.
>

Can an individual sport, book etc belong to many users?  If so then
you will need HABTM relationships between Users and Interests, if
going down Marnen's route (or between Interest and Sport if using your
original concept).

Colin

Colin

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to