数据库表命名约定
我试图找出数据库表的流行命名约定。
因此我有两个问题:
假设你有一张桌子,里面有人。每一行都是一个人。您如何称呼该表 - 'PERSONS' 或 'PERSON'?
现在假设有另一个名为“PERMISSIONS”的表,并且您正在创建一个新表,该表在人员与权限之间进行映射。您如何将该表命名为“PERSON_TO_PERMISSION”、“PERSON_PERMISSION_MAP”或其他名称?
我知道这里没有明确的规则,但我只是好奇什么是流行的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我们(我工作的公司)发现最适合我们的:
在实体表中,我们总是使用复数:人员、用户、权限等。
在many2many表中,我们使用单数形式:person_permission。
当我基于这个表创建一个类时,我(当然)使用单数:人,权限等。
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..
就我个人而言,我选择
有一般规则,但这是一个品味问题。
请参阅有关该主题的其他帖子:
https://stackoverflow.com/search?q=table+name+convention
Personally I go with
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