title: SQL: Foreign Key With multiple child values
body: <p>How would I setup a groups table with following relationship with a list of user:</p>
  
  <p>For example, lets say I have table of users:</p>
  
  <pre><code>              user_list
  -----------------------------------
  first_name | Last Name  | user_id |
  -----------------------------------
     john    | Appleseed  |  4      |
     Jasmin  | Applejuice |  6      |
  </code></pre>
  
  <p>Now I want to create a groups table. How can I create a table where users can be included in a group, or multiple groups. For example, John is included in the <code>Apple_group</code> but also included in the <code>Orage_group</code>. Jasmin is only included in the <code>Orange_group</code>:</p>
  
  <pre><code>                        groups
  ----------------------------------------------------
     group_name    | included_users_ids  | group_id  |
  ----------------------------------------------------
     Apple_group   |       4             |   1       |
     Orange_group  |       4, 6          |   6       |
  </code></pre>
  
  <p>Assuming the user_list table already exists, how would I setup the groups table? Furthermore I've read (see link below) that I shouldn't include multiple values in a single column.</p>
  
  <p><a href="https://stackoverflow.com/questions/9284344/inserting-a-foreign-key-with-multiple-values">Inserting a foreign key with multiple values</a></p>
  
  <p>So, my questions are:</p>
  
  <ol>
  <li><p>What would be the appropriate way to setup the groups table?</p></li>
  <li><p>What would the SQL be for doing so?</p></li>
  <li><p>How would this then be handled with PHP when wanting to set a user to a group?</p></li>
  </ol>