Rails DB convention info is a big fat secret?

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 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.

Dave Howell 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/ ?

Also, please check out the Rails mailing list.

And welcome to the fold! Sort of!

Devin

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
..and the API docs:
http://api.rubyonrails.com/classes/ActiveRecord/Base.html
..and the list of 'magic names'
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

ยทยทยท

On 12/20/05, Dave Howell <groups@grandfenwick.net> 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 home
page: how to name/design a database so Rails "gets it."