On Feb 28, 2012, at 2:09 PM, Mohamad El-Husseini wrote:

> How do you decide whether to use a string column or an id column to 
> differentiate between different types of records?
> 
> Suppose you have a relationships table that maps users to forums. The 
> possible relationships can be: subscriber, moderator, owner.
> 
> When does it make sense to move those relationship types to their own table 
> and reference them through a relationship_type_id column? What's the 
> criteria? Or is it better to use a string column to differentiate them?

Does the client/admin want to be able to change the names or number of these 
groups, or are you going to be updating it (and thus could make these sorts of 
code-level changes) when the management winds change? 

For a few options such as you have here, there's no reason to do it, IMO, since 
with an index, it's going to be just as fast or faster than joining another 
table by a numerical lookup. I would pull these options out into a constant so 
you only have one place to type them, too.

Walter

-- 
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 rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to