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 th
I'd call the link table this:
Remove_The_Surrogate_Primary_Key_From_The_Link_Table_Unless_You_Can_Prove_That_You_Really_Need_One
I have a convention which I find easy to see right away:
User
Role
User2Role
User
or Users
? What about things that end in an S? etc" (I would change this now if you just started the project)User
, Role
, and the xref table: UserRole
.UserRole
makes much more sense than RoleUser
.User_X_Role
or UserXRole
as well, if you like the extra verbosityWe have the same structure and call the link table UserRoles.
RoleUser
- I use alphabetic ordering (i.e. Role
comes before User
). That way when you're writing a query you won't have to try and remember which order you used to name the join table.
I also use singular as someone else mentioned - you don't have to try to remember! Works for me.
I try to keep things simple, but also be descriptive:
user_role_join