CodeIgniter Forums
Single Table Inheritance - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Single Table Inheritance (/thread-4738.html)



Single Table Inheritance - El Forum - 12-12-2007

[eluser]ricklee[/eluser]
Is this straightforward to do in CI?

http://www.juixe.com/techknow/index.php/2006/06/03/rails-single-table-inheritance/
http://www.ifisgeek.com/tutorials/implementing_single_table_inheritance_in_cakephp/
http://wiki.rubyonrails.org/rails/pages/SingleTableInheritance


Single Table Inheritance - El Forum - 12-13-2007

[eluser]sikkle[/eluser]
Model is just Model in ci, doesnt exist any kind of ORM at the moment.

hope this help.

good luck !


Single Table Inheritance - El Forum - 12-14-2007

[eluser]ricklee[/eluser]
oh yeah. i forgot Smile


Single Table Inheritance - El Forum - 12-14-2007

[eluser]sophistry[/eluser]
a quick look at the rails docs and examples tells me that this is not ORM - it is simply using one table to do the work of two or more tables. among other things, it's a way of handling heirarchical data (managers and employees are both people but using one table for them makes expressing their relationship hard - but you don't want two tables because that would mean redundant data, and you don't want to create a properly normalized set of tables because that's too much work ;-)

so, you come up with a shortcut. "single table inheritance" is one shortcut for organizing and giving the code framework access to a simple inheritance architecture in a database schema.

there have been multiple threads on this subject and related topics. use your keywords.

Thunder uk's Nested Sets is an option if you like the nested sets approach to organizing this type of data.

for general ORM there is the Rails Inspired: Rails style model interactions

there may be more... hope that helps inspire you to find/create more! this site is HUGE. - oh and the wiki.


Single Table Inheritance - El Forum - 12-14-2007

[eluser]ricklee[/eluser]
I did have ORM in mind actually when I was thinking about Single Table Inheritance (STI) in CI. What I want are difft models that subclass one parent model, but I want them all going to the same table.

In Rails, having the difft models means I can use difft validation filters, etc, while still mapping to the same table. Without using STI, they would have to go to difft tables.

I guess in CI (without ORM) it's not a big deal because you just make the database calls in each individual model and you can send the data wherever you want...


Single Table Inheritance - El Forum - 12-14-2007

[eluser]sophistry[/eluser]
why don't you subclass the model and override any methods in the base class that need to be different in the subclasses? it's hard to really understand what you want to do without specific examples, but perhaps using OOP will help you organize the approach?