title: MySql Error Code: 1005 Can't create table errno: 150
body: <p>MySql workbench reports that my syntax is error free. I can't figure out what's wrong with my database. Any ideas?</p>
  
  <pre><code>CREATE TABLE `users` (
      `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
      `login` VARCHAR(35) NOT NULL UNIQUE,
      `pass` VARCHAR(35) NOT NULL,
      `fname` VARCHAR(35),
      `lname` VARCHAR(35),
      `gender` VARCHAR(1),
      `phone` VARCHAR(12),
      `appointments` INT,
      `groups` INT(1) NOT NULL,
      FOREIGN KEY (`groups`) references `groups`(`gnumber`)
  );
  
  CREATE TABLE `groups` (
      `gname` VARCHAR(25) NOT NULL,
      `gnumber` INT(1) NOT NULL
  );
  
  INSERT INTO `groups`(`gname`, `gnumber`) values ('user', 0);
  INSERT INTO `groups`(`gname`, `gnumber`) values ('admin', 1);
  INSERT INTO `users`(`login`, `pass`, `groups`) values ('admin', 'secret', 1);
  </code></pre>