简体   繁体   中英

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.

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM