SQL连接表命名约定 [英] SQL Join Table Naming Convention

查看:73
本文介绍了SQL连接表命名约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个表:用户"和角色",并且有一个将这些表连接在一起的表.连接表中唯一的东西是链接两个表的ID.

I have 2 tables: Users and Roles, and I have a table that joins these together. The only thing in the join table is Ids that link the 2 tables.

我应该怎么称呼这张桌子?我从来没有真正看到过一个好的命名约定.

What should I call this table? I've never really seen a good naming convention for this.

我以前见过的公约:

  • UsersToRolesJoin
  • UsersToRolesLink
  • UsersToRolesMembership
  • UsersRoles

例如:

Users:  
Id  
Name

Roles:  
Id  
Name  

TableThatJoinsTheTwo:  
Id  
UserId  
RoleId  

推荐答案

似乎映射表存储着每个用户所属的所有角色.如果这是正确的,我将调用表UserRoles.

It seems like the mapping table is storing all the roles that each user is a member of. If this is correct I would call the table UserRoles.

此(IMO)正确地使表的意图多元化,而不是UsersRoles听起来很奇怪.

This correctly (IMO) pluralizes the intent of the table rather than UsersRoles which just sounds odd.

这篇关于SQL连接表命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆