Avi Y
Avi Y

Reputation: 2495

DB Tables naming conventions

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.

Upvotes: 0

Views: 330

Answers (2)

Hagai L
Hagai L

Reputation: 1613

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..

Upvotes: 3

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:

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

Upvotes: 1

Related Questions