From: Mat Schaffer Date: 2006-12-27T13:40:50+09:00 Subject: Re: Modified Single Table Inheritance On Dec 26, 2006, at 5:51 PM, Ryan Glover wrote: > My third solution, the one I am asking advice on, is this. > > I create a single table with the 4 common columns and a dozen columns > with names such as float1, float2, float3, ... , string1, string2, .. > etc. Creating enough columns of each type to cover my largest > subclass. > Then I use STI and for each class I map the generic columns to the > nicer > names inside the subclasses. So in one class float1 may be miles/hour > while in another class it might be turkeys/hectare. > > Does this sound like a reasonable approach? > > Also, how would I map the generic names to nice names in my > subclasses? > (I am a RoR noob) > > And of course, does anyone see a much better way to do what I have > proposed? Even though we're not technically on the RoR list, I thought this was still an interesting question for ORM, STI, OOP and probably some other acronyms too :) I'd be curious to hear just what it is that you're doing that needs 100s of classes, first. Sounds like you might be taking OOP a bit too far for your purposes. But to answer your question, I like the concept but it brings up fear of bugs. Dropping meaningful column names will wreak havoc on any cases where you have to write a query by hand. But everything is a trade off. Personally, I'd try the 100s of tables route first and see how it panned out. Best of luck. Sounds like a tricky one. -Mat