问个数据库的设计规范问题,假设有个用户表users 有个角色表roles 用户跟角色之间是多对多关系,那我中间表应该用users_roles 还是用user_role? Laravel 默认是用单数user_role我想知道有什么设计规范?
ringa_lee2017-04-17 15:06:41
is usually in the form of merge_user_role
or mapping_user_role
. Of course, user_role
is also possible, but it is easy to be confused with other tables. As for whether to use plural numbers, it mainly depends on the design of other tables. If your users
table is plural, you can probably use plural numbers here, but generally table names do not appear in plural form, so there is no need to use plural numbers here.
PHPz2017-04-17 15:06:41
There is no need to worry about whether it is singular or plural, just keep the style consistent
PHPz2017-04-17 15:06:41
There is no regulation, but it is recommended to use the odd number, because if the negative number takes up 2 more characters, the maximum length of the identifier in ORACLE is 30. In some cases, using the plural number will exceed the limit
伊谢尔伦2017-04-17 15:06:41
The naming convention only needs to be unified. If a single table name uses a plural number, it is also recommended to use a plural number in the name of the table relationship.