Choosing Names in Your Database

At work I was working on a simple Ruby on Rails project that is basically going to use CRUD to store, edit, and view information, something simple. I kept getting really weird errors with my scaffolding. After much mangling done with my database and code I found the problem was that I named a field in a table “System”.

This field was supposed to keep track of the Computer System so System was a nice shorthand for it. Well my shorthand cost over 6 hours of headaches. Turns out by using System, rails tried to create a new instance of it to reference the table but there already was a System in the namespace… namely “System” as in Kernelspace. So when my scaffold called System.send to try to read the data from the database it was actually calling the kernel of the , not the desired result you see.

After much googling and research I came across some links for my fellow rails developers (and myself for when I forget again). These are links to rails’ reserved words, the sql reserved words, and then just some words that should not be used in tables (ActiveRecord reserved words?)

Reserved Words in Ruby on Rails on the RoR wiki

Search for reserved words in various SQL database engines.

Words to NOT use in tables

Eric