# Class Table Inheritance implementation

**URL:** <https://www.ruby-forum.com/t/class-table-inheritance-implementation/62516>\
**Category:** Rails\
**Created:** [June 5, 2006, 7:42pm UTC](https://www.ruby-forum.com/t/class-table-inheritance-implementation/62516 "2006-06-05T19:42:53Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jsantos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@jsantos](https://www.ruby-forum.com/u/jsantos)\
**Post date:** [June 5, 2006, 7:42pm UTC](https://www.ruby-forum.com/t/class-table-inheritance-implementation/62516/1 "2006-06-05T19:42:53Z")

</div>

I know that Rails uses the Single-Table Inheritance as mentioned in the  
wiki ([Peak Obsession](http://wiki.rubyonrails.com/rails/pages/SingleTableInheritance)). I  
was wondering if there was an easy way of implementing Class Table  
Inheritance easily (one table per class) as defined in  
[P of EAA: Class Table Inheritance](http://www.martinfowler.com/eaaCatalog/classTableInheritance.html).

The model that I am used to is Class Table Inheritance, and for some  
uses it just feels more elegant to use that rather than Singe Table  
Inheritance.

---

<div class="post-metadata">

**Author:** ![jsantos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@jsantos](https://www.ruby-forum.com/u/jsantos)\
**Post date:** [June 5, 2006, 8:58pm UTC](https://www.ruby-forum.com/t/class-table-inheritance-implementation/62516/2 "2006-06-05T20:58:34Z")

</div>

What’s a good way to backup and restore a database and the images on  
the file system? Does anyone have any code to share? I have my own  
idea that I can write up but I don’t want to reinvent anything.

---

<div class="post-metadata">

**Author:** ![jsantos](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/779978/32.png) [@jsantos](https://www.ruby-forum.com/u/jsantos)\
**Post date:** [June 6, 2006, 5:30am UTC](https://www.ruby-forum.com/t/class-table-inheritance-implementation/62516/3 "2006-06-06T05:30:53Z")

</div>

JR Santos wrote:

> I know that Rails uses the Single-Table Inheritance as mentioned in the  
> wiki ([Peak Obsession](http://wiki.rubyonrails.com/rails/pages/SingleTableInheritance)). I  
> was wondering if there was an easy way of implementing Class Table  
> Inheritance easily (one table per class) as defined in  
> [P of EAA: Class Table Inheritance](http://www.martinfowler.com/eaaCatalog/classTableInheritance.html).
> 
> The model that I am used to is Class Table Inheritance, and for some  
> uses it just feels more elegant to use that rather than Singe Table  
> Inheritance.

I find SingleTable inheritance better as it has less maintainance.  
Having independent tables for object where only the behavior is  
different doesn’t make sense as databases are supposed to capture the  
persistent data and let your class define the behavior. It’s just too  
many tables to to hold each type of object.

ajay
