The convention here followed is English way of singular and plural forms. The database is nothing but collection of records, data in specific structure. And a 'class' as per Object Oriented Paradigm, it is a constructor and you can have multiple objects of similar type from it!
So it absolutely makes sense to name our tables in plural form (collection of data) and a class in the singular form.
Rails just does that! we name the tables of database as plurals and the respective classes as singular form of the same.
The above snapshot is taken from David's book on rails. As it shown here, we maintain the singular form on to the class names and plural on the table names.
Rails literally understands the singular and plural form of the words you use.
You take a note of the way we write the names:
- the table names in plural form all lower case letters.
- the class name in singular form with camel case/capitalized word
- What if the word does not have proper plural form?
- What if I do not want to follow this?
- As you can see in the above snapshot, the 'Person' as the class name and 'people' as the table name. And if you do not have proper/matching form for it, or you did not maintain the convention mentioned - you can use a keyword called set_table_name, in the model class where ever you are defining the construct.
- You can disable this feature globally with a variable under 'config/environment.rb' of the application. ActiveRecord::Base.pluralize_table_names = false
I guessed only the above questions, if you have more questions touch base with me and get them clarified.