views:

2255

answers:

13

Exact Duplicate

Table Naming Dilemma: Singular vs. Plural Names

Is it better to use singular or plural database table names ? Is there an accepted standard ?

I've heard arguments for and against it, what do you guys think ?

+2  A: 

I like to use singular names like Agent that have PK names like AgentID.

But that's just me :o)

wcm
+12  A: 

IMHO, Table names should be plular like Customers.

Class names should be singular like Customer if it maps to a row in Customers table.

Gulzar
Absolutely correct.
Chris Lively
One slight caveat/suggestion - where the name comprises several words you should pluralise where it makes linguistic sense rather than just the whole thing. Taking an example from below I would use: Customers CustomerAddresses (it's the address that's multiple) CustomerAddressesAuditTrail (the addresses keeps the plural as it's an audit trail applying to CustomerAddresses)
Jon Hopkins
a table is still a single entity, despite the fact that the entity contains a collection. The more I think about it the less sense pluralized table names make sense.
STW
Plural table names are redundant!
jakemcgraw
Yoooder: are you British, perchance? :-)
Ken
I'm half-Canadian, which makes me American English of sorts--but not British. What made you wonder?
STW
Please dont mind the people telling you to adopt certain style, its best to define your own, and to usually follow the practice(s) of the languages, tools, IDEs and frameworks that you use.
Azder
@Azder - Thats true. It is upto the others to accept or not.
Gulzar
added IMHO :)..sheesh so many downvotes and upvotes for this..
Gulzar
Yoooder: In British English, a collective object is often grammatically plural, e.g., "the committee were unable to agree" versus American English "the committee was unable to agree". So I hypothesized that a Brit might be more willing to use a singular noun for a collection of things.
Ken
+5  A: 

My personal philosophy is that using a plural database table name is redundant, unless you're only planning for the table to contain one row.

MattK
select * from customer seems "grammatically" incorrect to me...
Arnshea
@Arnshea: but when you think about what you're doing in pseudo code saying "get all parts of the table customers" doesn't make sense either.
STW
+5  A: 

I like to use plural forms, simply because one table contains several entities, so it seems more natural to me.

Linq to SQL converts plural form table names to singular when creating data entities. I assume that Microsoft would not have implemented this functionality if they considered plural forms for table names bad practice.

Adrian Grigore
so everything that holds other things should be plural? "I got on the busses and took out my boxes of kleenex to blow my noses full of boogerses filled with green stuff".
STW
No, you are getting on one bus. If however, you are storing multiple busses in one busses table, the table name should therefore be plural. Calling the table "bus" although it actually contains several busses makes little sense IMHO.
Adrian Grigore
+9  A: 

Singular, so you can have:

  • Customer
  • CustomerAddress
  • CustomerAddressAuditTrail

etc.

Tim Robinson
Definitely singular. +1
Tomalak
CustomersAddresses, CustomersAddressesAuditTrails :)
Russ Cam
+1 for singular. The code using them will definitely be using singular for class names, and I like my names for the same thing to match.
Sii
@Russ Cam: Sorry, but besides the fact that this sounds awful, the entity the table stores is a "CustomerAddress". The fact that there can be more than one of them is inherent, no need to reflect it in the table name.
Tomalak
+5  A: 

I like singular names but appear to be in the minority.

MarkR
Yes we are :) +1
wcm
I'm with you, but not because I like them--just because almost all of our are singular
STW
I'm switching my stance. I'm with you because it is the name of a single thing. You can select multiple widgets from a widget table, but the table itself isn't widgets--it just contains them.
STW
+2  A: 

IMHO it doesn't really matter, just do whatever is comfortable with you and the people that are using the database.

I think I subconsciously list main data tables with an s and "pick list" or foreign key tables and singular.

DForck42
+4  A: 

At my current company we use Plural for table names. The reasoning is this: If we have a Customers table we consider each row a Customer, so the table itself is a collection of customers.

Alexander Kahoun
but is the table itself customers? isn't it a Customer table?
STW
+1  A: 

The most important thing is to be consistent in your usage. It is annoying to have to remember which tables are plurals and which are not. Same thing with your field names, pick one stadard and use it. Don't make the poor developers have to determine if this table uses person_id or personid or peopleid or person$id, etc. It is amazing the amount of time you can waste when you don't have standards trying just to remember which table uses what.

HLGEM
+2  A: 

There is no should or must be this way or that way correct answer to this question. It's up to the designer of the database and software.

As for me, I usually use singular names becouse when I do the E-R diagram I have an entity Customer , not Customers, so I keep it same as to not get confused.

Ofcourse some frameworks do favor one style or another, so you should be best of to follow those practices when you notice them.

Azder
+1  A: 

As with lots of these types of questions the best answer is often "consistent". You can argue the table represents a single entity and as such deserves a singular name, or that it contains multiple entities so it should be plural. My advice is flip a coin and go with it for the entire database.

STW
+2  A: 

Well, obviously your database table names have absolutely got to be named in a "standard" fashion which I will hitherto arbitrarily define.

First, all tables names shall be prefixed with "t_". Following this, the singular entity name in StudlyCaps, e.g. "Customer". Immediately afterwards, this shall contain the number of columns created in the first version of the schema, for historical purposes, followed by an underscore, and the precise normal form of the data; either "1", "2", "3" or "B" for BCNF. Any higher normal forms shall be denoted by a "P".

Some examples of acceptable names are:

t_Customer_6_3
t_Order_5_B
t_OrderLine_4_2

I think my point is, it really doesn't matter, as long as the name is reasonably descriptive and naming is consistent.

Rob
If this were slashdot, I'd say +5 funny...
Denis Troller
+1  A: 

There are many arguments for each, but it all boils down to what you feel comfortable with. Neither is wrong.

What's really important is that you are consistent. Choose one standard and stick to it, which one you choose is of less importance.

Guffa