>> GreenByte.info By Nick Tong (quiksilv) | Supported by: TalkWebSolutions.co.uk

To pluralise or not to pluralise...

What are people thoughts on pluralising table names i.e. users, orders? I know the Reactor model was against this, and in Transfer I've followed that suit, so I use User, Order etc.

Thanks in advance.


 
Comments
Tom K's Gravatar As long as people are consistent, I don't think it really matters that much - as long as if you're working in a team, you have agreed beforehand.

It comes down to personal preference (a bit like CamelCase, and whether you name your tables just "contacts" or "tblContacts" etc..
# Posted By Tom K | 30/10/07 09:47 | Report abusive comment
todd sharp's Gravatar I think of my tables as a collection of items - so i'd use 'users' instead of 'user'

Also - be careful of reserved words - some dbms reserve the word 'user' so you'll have problems there.
# Posted By todd sharp | 30/10/07 10:32 | Report abusive comment
Ben Nadel's Gravatar I believe that using singular tables names and query names makes the most sense and cuts down on the amount of thinking that anyone has to do. Plurals are not consistent enough to be useful. Take "status" for instance. Is it, "statuses" or something fancy like "statii". I am like 99% sure its "statuses", but not sure enough that I don't have to go to dictionary.com to look it up before finalizing my DB structure.

Why go through that, when everyone knows what the single instance is.

As for query names, I think singular makes sense because you are never really referring to more than one record at a time.

But, I agree with Tom - what ever you do, as long as it is consistent, you are good.
# Posted By Ben Nadel | 30/10/07 10:33 | Report abusive comment
Kris Brixon's Gravatar I prefer singular. When dealing with the column in code you are only seeing one piece of data so it makes sense for the columns to be singular. Since I will be dealing with the columns in code much more than in SQL or DDL, I take the view of data as individual elements.

cfloop
#getUsers.USERS#

cfloop
#getUsers.USER#

To me the second one make logical sense. You are looping the plural object and grabbing the value from the singular object. The first one feels like I should also be looping USERS since it is plural.
# Posted By Kris Brixon | 30/10/07 11:13 | Report abusive comment
Tony Garcia's Gravatar I think the original post was asking about pluralising table names, but some of the comments seem to be talking about column names. I use plurals for table names, but singular for column names. So my "images" table will have an "imagename" column. I agree with the others that it comes down to personal preference and consistency is the key.
# Posted By Tony Garcia | 30/10/07 12:08 | Report abusive comment
Peter Boughton's Gravatar The convention in ERM/UML diagrams (at least the way I learnt them) is singular, and that always seems to make the most sense.


I am slightly baffled about why there is emphasis on consistancy in the comments - surely that's something that applies to everything, not just database naming? :S
# Posted By Peter Boughton | 30/10/07 22:42 | Report abusive comment
Sean Corfield's Gravatar Singular. Plurals are not consistent.
# Posted By Sean Corfield | 31/10/07 06:20 | Report abusive comment
brendan's Gravatar Singular is database standard
# Posted By brendan | 31/10/07 16:09 | Report abusive comment
Matt Williams's Gravatar User is a reserved word in MS SQL. So we changed it to Users. But with reactor's alias attribute, it is still User in the code.
# Posted By Matt Williams | 31/10/07 16:21 | Report abusive comment
Nick Tong's Gravatar Sorry everyone user was a bad example - please ignore.
# Posted By Nick Tong | 31/10/07 19:51 | Report abusive comment
Jane's Gravatar I'm adding my vote to singular. I agree with the comments about pluralising causing problems in knowing what the plurals of some words should be.
# Posted By Jane | 14/11/07 20:15 | Report abusive comment
James Marshall's Gravatar I learned DB design from O'Reilly books which suggested that table names should be singular, in much the same way that your classes names should be singular. The exercise that I picked this up from was demonstrating DB design via Entity relationship Diagrams, so that may well have had some bearing on things!
# Posted By James Marshall | 19/11/07 11:21 | Report abusive comment
Brian Kotek's Gravatar I prefer singular, but you have to be careful because on most RDBMSs, many common names like "user", "role", etc. are reserved words, and this can come back to bite you if you aren't aware of it or don't make exceptions to the rule of using singular table names.
# Posted By Brian Kotek | 19/11/07 12:52 | Report abusive comment
John Ivanoff's Gravatar We have discussed this at dfwcfug (http://groups.google.com/group/dfwcfug/browse_thre...
I think consistency is the answer.
# Posted By John Ivanoff | 19/11/07 15:54 | Report abusive comment
Calvin's Gravatar Singular, because plural IS inherently inconsistent:

Person can't be persons (people?)
Status is statuses not statuss (as mentioned above)
Mouse would be mice not mouses

And so forth. Effectively the variance between singular form and plural form varies wildly between words ranging from different spellings all together to just adding an s.
# Posted By Calvin | 19/11/07 20:56 | Report abusive comment
Nolan Erck's Gravatar I tend to use plurral more than singular, but I will also leave that up to a) what is the best context for the app in question and b) is the singular a reserved word?

I'm also one of those that regularly uses "tbl", "tlkp" and "tlnk" prefixes on my database table names -- I'd rather type a mere 3 more character than wonder what the purpose is of a particular item in my database.

.02
# Posted By Nolan Erck | 20/11/07 01:12 | Report abusive comment
Kevin Roche's Gravatar Nick,

Use singular. Most database tools will expect that and produce sesible results.
# Posted By Kevin Roche | 22/11/07 14:08 | Report abusive comment
Julian Halliwell's Gravatar I've flip-flopped on this over the years. As a newbie, plural seemed more logical since tables almost always contain more than one row, but then I learnt that singular was the orthodox approach so toed that line. But after a while I went back to plural: not only was I bitten by the reserved words issue a few times but I just feel plural table names make my sql statements read more naturally. Does the inconsistency of plurals in English matter? Yes if you're building dynamic references from object names etc (e.g Reactor), but otherwise I have no problem with:

SELECT person.name FROM people AS person

Note the singular alias so that the column reference reads as a single item.
# Posted By Julian Halliwell | 23/11/07 08:40 | Report abusive comment
Mike Rankin's Gravatar Singular is my preference. In addition to removing the ambiguity mentioned above, it also makes it easier to work with metadata. I also capitalize the first letter of my tables. It makes translations like User -> getUser() really easy to do programmatically.
# Posted By Mike Rankin | 26/11/07 15:15 | Report abusive comment
BlogCFC was created by Raymond Camden. This blog is running version 5.5.1.