title: How to connect the users table to the roles table (using the table user_roles)?
body: <p>I need to create a basic database for user authentication. So far, every user has a name, a password and a role. I've found this somewhere on the Internet, which looks quite promising:</p>
  
  <pre><code>create table if not exists users (
    id int unsigned not null auto_increment,
    username varchar(100) not null,
    password binary(60) not null,
    primary key(id),
    unique(username)
  );
  
  create table if not exists roles (
    id int unsigned not null auto_increment,
    role varchar(100) not null,
    primary key(id),
    unique(role)
  );
  
  create table if not exists user_roles (
    user_id int unsigned not null,
    role_id int unsigned not null,
    unique(user_id, role_id),
    index(user_id)
  );
  </code></pre>
  
  <p>But... if I would create new users, how would I fill the <code>user_roles</code> table? I have a feeling there is some "automatic way" to do this, but I have totally no idea (being a database noob :-)). How could I somehow connect a user to a role?</p>