Xaprb

Stay curious!

Singular vs. plural table names

with 9 comments

Is it better to name SQL tables with singular or plural names? In my opinion, the most important thing to do is pick one and stick to it. Programmers will always argue about singular vs. plural, and it is possible to make a valid case for both.

My strong preference is singular. The name is the table name; it is not the name of the tuples. A bag does not become a “bags” when you put apples in it. It is still a bag.

You might take this to extremes and reply,

According to that argument, every table should be named “table,” right? If you are naming the table and not the tuples, every table should have the same name. So the table should be named after the contents, and should be plural.

There is such a strong argument for either side, I don’t think you can appeal to logic to solve the problem. That’s why, even though I gave my reasons for preferring singular above, when I actually get into this discussion, I simply say “there are good reasons for either side, but I just like singular names better.” That way nobody can argue with me, because they’re just arguing with my taste, not facts. It’s hard to argue with taste without sounding immature, but it’s easy to refute facts. This is part of my devious plan to make people seem immature when they disagree with me *heh heh*

Of course, I actually do like singular better because in my opinion, it is less confusing. This is a little hard to quantify. But especially when you extend the discussion to naming views, stored procedures, indexes and primary keys which depend on the table, and whose names should be influenced by the table name, my personal experience is singular table names make everything clearer.

Written by Baron Schwartz

September 28th, 2005 at 3:40 pm

Posted in Uncategorized

9 Responses to 'Singular vs. plural table names'

Subscribe to comments with RSS

  1. I recently blogged about whether to use singular vs. plural table names.

    Eric Swanson

    12 Sep 06 at 8:30 pm

  2. I have a bag, it contains apples,
    so I wrote apples on the outside.
    I am not sure what to do when I have eaten all but one.
    Should I have written ‘apple bag’ instead?

    Douglas

    6 Oct 06 at 2:10 am

  3. An Apple Bags is

    a great autumn dilemma

    springtime will come soon

    Xaprb

    6 Oct 06 at 8:31 am

  4. We are absolutely sure about tables are containing more than one record right? (okay sometimes we put only one record but it’s rare) so i believe you don’t have to make it clear. But i’m missing the plural also.

    kismet

    8 Jul 08 at 9:14 am

  5. If we were all Chinese, we wouldn’t be having this discussion. =)

    James

    3 Apr 09 at 9:30 pm

  6. @James: ? :)

    Hao

    21 Aug 09 at 9:21 pm

  7. @James: dui :)

    Hao

    21 Aug 09 at 9:21 pm

  8. If I have a bag of apples, I don’t call it “bag” or “bags”. I call it “apples”. And if I have a table of customers, I don’t call it “table” or “tables”, I call it “customers”.

    Logically, that makes the most sense to me. However, I’m getting into the ADO.NET Entity Frameworks and am finding reasons to break what is most logical to me in favor of something that can produce better constructs within that paradigm.

    EF has a name for both an entity and an entity set. That’s why I’m researching this today. However, my mind has not yet been made up.

    Jonathan Wood

    7 Jul 10 at 3:52 pm

  9. Maybe Microsoft should follow the singular convention too and rename “my documents” to “my document” and “Program Files” to “Program File”, the “Users” folder to “User”, “Downloads” to “Download”…. that all makes much more sense doesn’t it? The drawer where I keep my bank statements will be labeled… “statement” lol

    HoppingYop

    21 Jul 11 at 11:07 am

Leave a Reply