Hi-

I'm designing the database for my app and am trying to do it as intelligently as possible. I'm trying to avoid an explosion of tables and thought single table inheritance (STI) might be the answer..... Is it me or is the use of foreign key constraints (nearly?) impossible when making associations between entities using STI? Any thoughts on this would be extremely helpful.

Thanks

Hi-

I'm designing the database for my app and am trying to do it as intelligently as possible. I'm trying to avoid an explosion of tables and thought single table inheritance (STI) might be the answer..... Is it me or is the use of foreign key constraints (nearly?) impossible when making associations between entities using STI? Any thoughts on this would be extremely helpful.

Thanks

From my experience using STI isn't too bad so long as too many models are involved; it can get messy using the rails method with the 'type' column.

Of course you could try with CTI but its experimental at the moment and I wouldn't use it for anything critical

http://wiki.rubyonrails.org/rails/pages/ClassTableInheritanceInRails

For more complicated uses I'd try to steer clear of inheritance in rails and use relationships between models; not always the cleanest but probably more reliable/robust in the long run

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.