[Twisted-Python] coding standard: plurals for database table names

Clark C. Evans cce at clarkevans.com
Sun Apr 6 13:53:04 EDT 2003

I noticed  in the Twisted Coding Standard that...

   "Database tables shall be named with plural nouns"

I'd like to question this standard for several reasons:

  1. There is not one single rule for forming plurals.
     In particular, some plurals have the same spelling
     as their singluar, 'deer'; furthermore some plurals
     have different forms, 'people' instead of 'persons'.
     Sometimes it is 's' or 'es'.  These differences are
     especially hard for those who have English as a 
     a second language.
  2. Tables are to rows as classes are to instances.
     We name Classes singluar, and as such tables should
     also be singluar.  This makes mapping rules easier.

  3. It is helpful to name foreign key columns as the
     same name as the table that they are coming from.
     And it makes little sense to use plurals for 
     column names, for example, when the person table
     may have a 1-M relationship with address, it could
     have a 'address' column name, which is obviously
     a foreign key to the 'address' table.   If you used
     plurals for the table name it brings up the 
     question... do you use plurals for the column name?
     I've seen it done.  *ick*

  4. I often use the double underscore method for link
     tables which represent M-M relationships.  In this
     case good names are hard to find.  For example, a
     link from a person to their address... how do you
     name this?   I use person__address.  If you use
     plurals then this becomes persons__addresses, 
     dooable but ugly.

  5. While there are astechic reasons for this (above)
     the resons become all the more important when 
     you want to build automatic tools for searching 
     over schemata, etc.  In this case, using plurals
     only adds one extra (unnecessary) step in the
     automated translation of plural table names to 
     singluar column and or class names.

In short, I'd recommend singluar nouns, with M-M
link tables as one__two where one and two are 
tables being linked to.



More information about the Twisted-Python mailing list