Skip to content

Instantly share code, notes, and snippets.

@rob-murray
Last active June 1, 2016 14:12
Show Gist options
  • Save rob-murray/5e8cff515bca63b662be3419f64a59db to your computer and use it in GitHub Desktop.
Save rob-murray/5e8cff515bca63b662be3419f64a59db to your computer and use it in GitHub Desktop.
Referenced from http://edgeguides.rubyonrails.org/active_record_basics.html#naming-conventions
## Table naming conventions
Pluralised =>
* User[object] becomes `users` table name
* Person[object] becomes `people` table name
Join Tables =>
Complicated but done by comparing the two table names as strings -> http://api.rubyonrails.org/classes/ActiveRecord/Associations/ClassMethods.html#method-i-has_and_belongs_to_many
## Column naming conventions
There will always be `created_at` and `updated_at` *datetime* columns for timestamps
Foreign keys are the singular version of the relation with `_id` suffixes
*date* columns have `_on` suffixes
*datetime* columns have `_at` suffixes
*time* columns (referring to a time of day with no date) with _time suffixes
See reserved column names, such as `type` !
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment