# AR: Model on several tables

**URL:** <https://www.ruby-forum.com/t/ar-model-on-several-tables/96618>\
**Category:** Rails\
**Created:** [June 30, 2006, 9:56am UTC](https://www.ruby-forum.com/t/ar-model-on-several-tables/96618 "2006-06-30T09:56:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jean-Etienne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@Jean-Etienne](https://www.ruby-forum.com/u/Jean-Etienne)\
**Post date:** [June 30, 2006, 9:56am UTC](https://www.ruby-forum.com/t/ar-model-on-several-tables/96618/1 "2006-06-30T09:56:37Z")

</div>

Hi,

Is it possible to have a Model where columns are not in one table, but  
two tables?

Jean-Etienne

---

<div class="post-metadata">

**Author:** ![Jean-Etienne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@Jean-Etienne](https://www.ruby-forum.com/u/Jean-Etienne)\
**Post date:** [June 30, 2006, 11:03am UTC](https://www.ruby-forum.com/t/ar-model-on-several-tables/96618/2 "2006-06-30T11:03:33Z")

</div>

Not that I’m aware of. You may be able to use a view in the database  
to emulate one table… worth a shot. Why do you need to do this?

-Jonathan.

---

<div class="post-metadata">

**Author:** ![Jean-Etienne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@Jean-Etienne](https://www.ruby-forum.com/u/Jean-Etienne)\
**Post date:** [June 30, 2006, 12:22pm UTC](https://www.ruby-forum.com/t/ar-model-on-several-tables/96618/3 "2006-06-30T12:22:17Z")

</div>

Jonathan V. wrote:

> Not that I’m aware of. You may be able to use a view in the database  
> to emulate one table… worth a shot. Why do you need to do this?
> 
> -Jonathan.

I have a a lot of models “almost” the same, and was thinking to go for  
Class Table Inheritance.  
I have several remarks about STI:

1. Locking: it will lock a model when somebody updates another one…
2. I do not see how to use reflection to get model properties. I  
probably need to maintain a table to know what are the properties for  
all models. It doesn’t look right to me.
3. ActiveRecord updates all properties all the time, so UPDATE will be  
huge.

Last solution would to go for Concrete Table Inheritance, but again, I  
need to hash the identifier generation, keep a table with oids and class  
to resolve object types, … I seems to me too huge infrastructure to  
build for what I need (not so many documents).

Any advice?

---

<div class="post-metadata">

**Author:** ![Jean-Etienne](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bbe5ce/32.png) [@Jean-Etienne](https://www.ruby-forum.com/u/Jean-Etienne)\
**Post date:** [July 1, 2006, 3:43pm UTC](https://www.ruby-forum.com/t/ar-model-on-several-tables/96618/4 "2006-07-01T15:43:07Z")

</div>

Anybody to give her/his experience on Concrete Table Inheritance ?
