0

For example, you have tables Users and Groups; a user can be member of many groups, and a group has many users.

So how would you name the table that connects them?

Should it be user_groups or group_members ?

Personally, I think the latter is better.

Though it depends. If I want to know the groups of a user, I think the former is better. If I want to know the members of a certain group, I think the latter is better. However, I think it's not right to create both table since they are the same.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Jonathan Lightbringer
  • 435
  • 2
  • 12
  • 27
  • 1
    Define *better* - how is one naming *better* than the other? The important thing is: **you** need to come up with a naming convention, and then **stick to it** - what it is is really secondary .... – marc_s Jan 27 '18 at 12:31
  • 1
    This is opinion based (so I'm voting to close). My choice would be `UserGroups`. It would have the names of the two related entities and be plural. – Gordon Linoff Jan 27 '18 at 12:34
  • if is it used only for Users, then User_Groups, if is it used by other tables as well, then Group_Member. Aside from that, you need to keep in mind the tables list order, for instance, if you name it User_Groups, it'll be listed under User table, but if you named it Group_Member, it'll be listed in the top tables as tables are listing in ASC order. – iSR5 Jan 27 '18 at 12:57

2 Answers2

0

I would like the table name to help me identify the tables from which it holds the data. Although group_members seems more logical, I would prefer users_groups as it clearly mentions the tables from which it holds data.

0

See first reply from What should I name a table that maps two tables together?

Your question can be considered as duplicate, because already exist one with a good answer there.

And my personal answer for your question, I prefer to use a prefix for all many-to-many tables, example : MapGroupUser, where "Map" is the prefix. So, all tables of this particular type will be different from the others

AlleXyS
  • 2,476
  • 2
  • 17
  • 37