9

Yes, I know, it is possible to quote the name of the table, but it is sometimes improper.

If there is no alternative, I name this table as "users", although this semantically unneeded plural makes things a little bit inconsistent.

What alternative solutions do exist?

6
  • 2
    I prefer to name my tables in the plural if they are supposed to contain more than one "thing". Commented Jul 10, 2014 at 17:23
  • Religious war. A bag for apples is still the "apple bag" not the "apples bag"! You might have a nuclear power plant with an IT system with a table called Catastrophic_Meltdown - a table in which hopefully you would never want any records at all!
    – Vérace
    Commented Jul 10, 2014 at 17:40
  • I'm in favour of singular names for tables but using plural names has one advantage: we can use Groups, Users, Orders, Plans, Likes, Keys, etc (which unfortunately we can't if we stick to singular.) Commented Jul 10, 2014 at 18:39
  • 1
    @Vérace that would be AppleBagItems and CatastrophicMeltdownEvents. I find it to be always possible to use plural names.
    – usr
    Commented Jul 10, 2014 at 23:27
  • 1
    UserData would be one of the best options. Please, don't use languages other than English and of course, don't make a password out of your table name (something like Y00ZER would be the worst) Commented Feb 13, 2020 at 9:29

3 Answers 3

1

I often use non-English words, for me usaideoir (Irish) or utilisateur (French). Pehaps for you, benutzer (German), felhasznalo (Hungarian) or korisnik (Croatian)? Accents have been removed. I know it adds to the typing, but it can save time when you want to port to a new db - no quotes. Anyway, quoting identifiers is a notorious source of errors.

Tables (also columns) can also generally have a comment associated with them which can be used to indicate any departures from a standard (i.e. in this case the English language!).

5
  • This could be a problem when working with developers who know nothing about Irish/French/German/Hunrarian/Croation. The Irish and French I could probably guess at, but the Croatian one I'd never guess what it was just by looking at the name. Commented Jul 10, 2014 at 17:23
  • 2
    Big gratulation to your language estimation technology! :-)
    – peterh
    Commented Jul 10, 2014 at 17:25
  • @FrustratedWithFormsDesigner - COMMENT ON TABLE... beats the bugs with "Field Name Unknown: User" (time wasted checking field exists...). Peter - Thanks!
    – Vérace
    Commented Jul 10, 2014 at 17:34
  • yeah this definitely won't confuse anyone.
    – niico
    Commented Jun 24, 2016 at 15:44
  • Tables (also columns) can also generally have a comment associated with them which can be used to indicate any departures from a standard (i.e. in this case the English language!).
    – Vérace
    Commented Feb 11, 2018 at 17:57
4

Put some context in the name. If the table is for a CMS, maybe name the table CMS_USER. If it's a reporting tool, REPORT_USER. You could include the application name in it, as ${applicationName}_USER. Failing those, would just APPLICATION_USER be OK? I did once see a table named UZER, along the tradition of naming a variable representing a class as clazz, but I'm not too fond of that one. You could do something like U5ER, since a "5" sort of looks like an "S". Or you could just go totally phonetic and name the table something like YOOZER.

3

For table names, you can prefix your tables with t, tbl, etc.

CREATE TABLE schema.tuser

Personally, I like to make my tables plural, as if it's a table of users, rather than a table of user.

CREATE TABLE schema.users

If you don't like either of those options, you can always be more descriptive when making your tables. What kind of users are they? What is the database for?

CREATE TABLE schema.appusers

Not the answer you're looking for? Browse other questions tagged or ask your own question.