# Rails DB convention info is a big fat secret?

**URL:** <https://www.ruby-forum.com/t/rails-db-convention-info-is-a-big-fat-secret/50789>\
**Category:** Ruby\
**Created:** [December 21, 2005, 5:41am UTC](https://www.ruby-forum.com/t/rails-db-convention-info-is-a-big-fat-secret/50789 "2005-12-21T05:41:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![daveh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@daveh](https://www.ruby-forum.com/u/daveh)\
**Post date:** [December 21, 2005, 5:41am UTC](https://www.ruby-forum.com/t/rails-db-convention-info-is-a-big-fat-secret/50789/1 "2005-12-21T05:41:14Z")

</div>

I started learning Ruby in part so I could do some web scripting, and  
have already twice tried installing Rails, with my usual catastrophic  
installer-malfunction-experiences with Ruby-related material. (I like  
Ruby, but I _hate_ having to install it.) At the moment I have a brand  
new XServe with a nice fresh install of stuff. I have not yet tortured  
it (and myself) with Ruby or Rails yet. Ruby’s just on my laptop for  
now, and Rails isn’t going on anything until I’m ready.

One of the “getting ready” things is rebuilding and repopulating a  
PostgreSQL database. As it happens, I can afford to redesign the  
schema, since we’re retiring the current apps that use it. Now, I’ve  
seen bits and pieces of some very specific expectations that Rails has  
for databases.

So why is the complete description a Rails-conformant database a giant  
secret? I’ve Googled all over the web trying to find what, logically,  
ought to be right up front in big bold type on the [rubyonrails.org](http://rubyonrails.org) home  
page: how to name/design a database so Rails “gets it.”

The only thing I’ve found so far that even comes close was in a PDF  
file, specifically Jeffrey Hick’s “Many to Many” tutorial. Um? That’s  
preposterously obscure, or so it seems to me.

So far, I’ve got that it wants my table names to be plural, that trying  
to use anything other than an autoincrementing integer named “id” for  
the identity column is likely to be a real PITA, that foreign keys have  
to be [tablename][underscore]“id”, and (a secret exclusively in Hick’s  
article), linking tables must be named after the two tables to which  
they link, and in alphabetical order!

So what other secrets should I have, and why isn’t this the very first  
article in the database-related Wiki articles or otherwise located so  
that I’m tripping over it, instead of scratching my head?

Lugubriously,  
a not-easily-dissuaded Ruby newbie.

---

<div class="post-metadata">

**Author:** ![daveh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@daveh](https://www.ruby-forum.com/u/daveh)\
**Post date:** [December 21, 2005, 6:11am UTC](https://www.ruby-forum.com/t/rails-db-convention-info-is-a-big-fat-secret/50789/2 "2005-12-21T06:11:20Z")

</div>

Dave H. wrote:

> I started learning Ruby in part so I could do some web scripting, and  
> have already twice tried installing Rails, with my usual catastrophic  
> installer-malfunction-experiences with Ruby-related material. (I like  
> Ruby, but I _hate_ having to install it.) At the moment I have a brand  
> new XServe with a nice fresh install of stuff. I have not yet tortured  
> it (and myself) with Ruby or Rails yet.

My recommendation: Use DarwinPorts to install Ruby, RubyGems, and your  
DB, and use RubyGems to install Rails and any other Ruby libraries, and  
you’ll be much happier. (Fink might be fine, instead of DP; never used  
it.)

> that foreign keys have to be [tablename][underscore]“id”, and (a  
> secret exclusively in Hick’s article), linking tables must be named  
> after the two tables to which they link, and in alphabetical order!

Have you been to [http://api.rubyonrails.org/](http://api.rubyonrails.org/) ?

Also, please check out the Rails mailing list.

And welcome to the fold! Sort of!

Devin

---

<div class="post-metadata">

**Author:** ![daveh](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/85e7bf/32.png) [@daveh](https://www.ruby-forum.com/u/daveh)\
**Post date:** [December 21, 2005, 6:17am UTC](https://www.ruby-forum.com/t/rails-db-convention-info-is-a-big-fat-secret/50789/3 "2005-12-21T06:17:21Z")

</div>

On 12/20/05, Dave H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> So why is the complete description a Rails-conformant database a giant  
> secret? I’ve Googled all over the web trying to find what, logically,  
> ought to be right up front in big bold type on the [rubyonrails.org](http://rubyonrails.org) home  
> page: how to name/design a database so Rails “gets it.”

In general you’ll have better luck on the Rails mailing list, but…  
Check out the readme:  
[http://api.rubyonrails.com/files/vendor/rails/activerecord/README.html](http://api.rubyonrails.com/files/vendor/rails/activerecord/README.html)  
…and the API docs:  
[http://api.rubyonrails.com/classes/ActiveRecord/Base.html](http://api.rubyonrails.com/classes/ActiveRecord/Base.html)  
…and the list of ‘magic names’  
[http://wiki.rubyonrails.com/rails/pages/MagicFieldNames](http://wiki.rubyonrails.com/rails/pages/MagicFieldNames)

Also, most people are just buying the book. It’s quite nice, and  
available in PDF form:  
[http://www.pragmaticprogrammer.com/titles/rails/index.html](http://www.pragmaticprogrammer.com/titles/rails/index.html)
