This comes from the Rails world, but is a pretty generic question about Single Table Inheritance. They only reason I'm asking this is that people keep pushing STI on me when there is no obvious reason for it. May be I'm missing some point? Please consider these two scenarios for displaying & storing page contents for various pages on the website:
Scenario 1
class ContentItem < ActiveRecord::Base
belongs_to category
end
Here all the possible items are stored in one table, only distinguished by the category. Then wherever you need to display all news items or faq items , you just do a call to category.
Scenario 2
class ContentItem < ActiveRecord::Base
end
class FaqItem < ContentItem
end
class NewsItem < ContentItem
end
Here there is no need for category, but if you ever need to add another type of ContentItem, you need to create another model, and another and so on.
My problem with scenario #2 is that FaqItem & NewsItems are exactly the same. They are never going to be different. The only difference is that they can be modified by different people ( Site Admin vs PR person for news) .
So while both approaches are ok, why choose one scenario over the other in this particular instance?