views:

81

answers:

2

Hello, I am trying to find out what are the popular naming conventions for DB tables.

Therefor I have 2 questions:

Lets say you have a table with persons in it. Each row is a person. How would you call the table - 'PERSONS' or 'PERSON'?

Now lets say there is another table named 'PERMISSIONS' and you are creating a new table which is mapping between persons to permissions. How would you call this table, 'PERSON_TO_PERMISSION', 'PERSON_PERMISSION_MAP' or anything else?

I know there isn't a definite rule here but I am just curious on what is popular.

+1  A: 

Personally I go with

  • Person: I'm considering the table name as the description of a single record in it.
  • PersonPermission: When I have a conjunction table, I concatenate both table names

There are general rules, but it's a matter of taste.

See other posts on the topic:

http://stackoverflow.com/search?q=table+name+convention

Mike Gleason jr Couturier
That's exactly how we do it too.
Garry
+2  A: 

Here what we (the company I work in) found that is best for us: In tables that are entities we always use plural :Persons, users, permissions etc.. In many2many tables we use the singular form : person_permission.

when I create a class based on this table I use (ofcourse) the singular : person, permission etc..

Hagai
I personally don't like plurals for table names, as ORM tend to provide a plural form for them... so you end up with Memberss when referring to the whole table and Members when referring to a single entity.
Mike Gleason jr Couturier
we have our own generator. so "Users" becomes user , and when I need a list of objects we still have "Users". I think we are not unique in this.
Hagai