1
votes

I am not able to zero down on how to organize the database for my rails application. The questions I found here and on Google discuss problems with limited class inheritance. What if the number of classes is very high. How should one organize the classes if I want to have one class per type for all the types identified in the schema.org hierarchy?

Although I have found some support for Class Table Inheritance like this gem called CITIER, implementing Single Table Inheritance seems simpler and better supported.

Should I stick with STI or try to use MTI?

1
I found this interesting post on Multiple Table Inheritance. mediumexposure.com/multiple-table-inheritance-active-recordrohitmishra

1 Answers

0
votes

IMHO, STI makes sense where the two objects, which will be encapsulated by the classes, share almost all of their relevant attributes. So, at a newspaper it might make sense to have an Employee class that has an Editor class that inherits from it (class Editor < Employee) because an editor maybe just a very slightly different kind of employee. A problem with STI may arise when the to objects you are modeling have too much not in common, even though it makes sense to see one as a sub-class of the other. The single table can become too sparsely populated. In this case, I find it more efficient to use "has" and "belongs to" to model the object. YMMV.