# Rails noob db questions

**URL:** <https://www.ruby-forum.com/t/rails-noob-db-questions/88071>\
**Category:** Rails\
**Created:** [March 28, 2006, 2:02am UTC](https://www.ruby-forum.com/t/rails-noob-db-questions/88071 "2006-03-28T02:02:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Josh\_McDonald](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@Josh\_McDonald](https://www.ruby-forum.com/u/Josh_McDonald)\
**Post date:** [March 28, 2006, 2:02am UTC](https://www.ruby-forum.com/t/rails-noob-db-questions/88071/1 "2006-03-28T02:02:59Z")

</div>

Hi, I’m trying to get my head around rails, but the documentation seems  
sparse at best (and [manuals.rubyonrails.com](http://manuals.rubyonrails.com) is unreachable from my  
location  
for whatever reason). I’m trying to figure out a few things:

1. The documentation for the magicfields mentions using datetimes  
instead of  
timestamps, which pgsql doesn’t appear to support. What’s the answer in  
this  
case?

2. All the tutorials seem to be geared towards trivial data  
relationships.  
What if I have table SHOP and table PERSON, but each record in SHOP has  
a  
OWNER, MANAGER, and a collection of EMPLOYEES. How should you structure  
this  
in your tablespace to take the best advantage of activerecord?

3. Am I wrong in the assumption that all this needs to be sorted out at  
the  
database level before I go and generate models and controllers? Where do  
you  
put code that you don’t want to get blatted if and when the schema  
changes  
and you need to regenerate?

TIA,  
-Josh

–  
“wookin’ pa nub in all da wong paces, wookin’ pa nub”

```
          [Josh 'G-Funk' McDonald] -- [0437 221 380]

```

---

<div class="post-metadata">

**Author:** ![Josh\_McDonald](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/3e96dc/32.png) [@Josh\_McDonald](https://www.ruby-forum.com/u/Josh_McDonald)\
**Post date:** [March 28, 2006, 2:30am UTC](https://www.ruby-forum.com/t/rails-noob-db-questions/88071/2 "2006-03-28T02:30:24Z")

</div>

On Tue, 2006-03-28 at 10:01 +1000, Josh McDonald wrote:

> Hi, I’m trying to get my head around rails, but the documentation  
> seems sparse at best (and [manuals.rubyonrails.com](http://manuals.rubyonrails.com) is unreachable from  
> my location for whatever reason). I’m trying to figure out a few  
> things:
> 
> 1. The documentation for the magicfields mentions using datetimes  
> instead of timestamps, which pgsql doesn’t appear to support. What’s  
> the answer in this case?

* * *

## fields named ‘created\_on’ ‘updated\_on’ ‘created\_at’ ‘updated\_at’ should work

> 1. All the tutorials seem to be geared towards trivial data  
> relationships. What if I have table SHOP and table PERSON, but each  
> record in SHOP has a OWNER, MANAGER, and a collection of EMPLOYEES.  
> How should you structure this in your tablespace to take the best  
> advantage of activerecord?

* * *

## I think the Active Web D. With Rails discusses this - so does some of the wiki pages…I think it’s called STI (single table inheritance) - that would be one way of handling the employees, owners, managers within one table.

> 1. Am I wrong in the assumption that all this needs to be sorted out  
> at the database level before I go and generate models and controllers?  
> Where do you put code that you don’t want to get blatted if and when  
> the schema changes and you need to regenerate?

* * *

Not at all…I think you are on the mark…get it sorted out now before  
you have to go back and fix a bunch of forms/lists/etc.

Craig
