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
Its good to name join table by using names of tables which it connects. For example two tables "products" and "product_tags", and the joining table is called "product_product_tags". The big advantage is that from this name you can immediatelly say which tables its joining together. When you have 50 and more tables in your DB its good to have it like this and you no longer need to think about joining tables purposes.
We've always used the names of the two tables followed by the word, 'Links'. So in your example our table name would be 'UsersRolesLinks'.
The database represents am enterprise, right? So what do the people in that enterprise call the relationship?
Here are some I do know:
employee reports to line manager == org chart
student takes course == enrolment
woman marries man == marriages
When in doubt, ask a domain expert within the enterprise.
2 approaches:
where you will only ever have one relationship between the tables: join table could be RoleUser or Role_User. Go alphabetic with your name order, Role 1st, then User, then you don't have to try to remember!
where you will have multiple relationships between the tables: relationshipname - e.g. you might have a list of regular roles for users, and you might have a list of potential, or past roles for users. Same 2 tables, but different relationships. Then you might have RoleUser_Current and RoleUser_Past.
I've always gone with something like : rel_user_roles or relUserRoles. Which table goes first usually just depends on where it is in the data model.
This is the convention at my workplace:
UsersXRoles