In an application where users can belong to multiple groups, I'm currently storing their groups in a column called groups
as a binary. Every four bytes is a 32 bit integer which is the GroupID
. However, this means that to enumerate all the users in a group I have to programatically select all users, and manually find out if they contain that group.
Another method was to use a unicode string, where each character is the integer denoting a group, and this makes searching easy, but is a bit of a fudge.
Another method is to create a separate table, linking users to groups. One column called UserID
and another called GroupID
.
Which of these ways would be the best to do it? Or is there a better way?