About a relationship between the three collections

I want to make a community management app.
In this app, A user belongs to multiple groups, and each user has roles such as administrator, participant, and editor in each group. The role of the user is different for each group to which it belongs.
In this case, how should the database be designed?

When you say “Multiple groups”, are you meaning a set number of groups or a variable number of groups?

thank you for your reply !
I mean variable number of groups.

Hi @kengota,

As an idea:

  • you have “Groups” collection, where you store Group name, and other info related to the group itself
  • you have “MemberStatus” collection, where you store the list of statuses
  • you have “GroupMembers” collection, where you store information about members of the groups. Here you have (1) a relation to Users (one User can have multiple GroupMember records, but GroupMember belongs to one user); (2) a relation to Groups (one GroupMember can belong only to one Group, but the Group can have many GroupMembers), and (3) relation to MemberStatus collection, again - one to many (GroupMember may have only one MemberStatus).

As a result, you may have something like this:

I prefer this approach, as there are no Many-to-Many relationships involved, which are (IMHO) not very fast. But that’s my personal opinion.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.