title: What is the best way to add users to multiple groups in a database?
body: <p>In an application where users can belong to multiple groups, I'm currently storing their groups in a column called <code>groups</code> as a binary. Every four bytes is a 32 bit integer which is the <code>GroupID</code>. 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.</p>
  
  <p>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.</p>
  
  <p>Another method is to create a separate table, linking users to groups. One column called <code>UserID</code> and another called <code>GroupID</code>.</p>
  
  <p>Which of these ways would be the best to do it? Or is there a better way?</p>