title: MySQL Err No 150 Foreign Key Constraint is Incorrectly Formed
body: <p>I'm trying to create a many to many relation table for <code>products</code> and <code>categories</code> named <code>product_categories</code>.</p>
  <p>Using: MySQL, INNODB.
  IDs are UUID4 ,using <code>char(36)</code> for the ID fields.</p>
  <pre><code>create table product_categories
  (
      product_id  char(36) not null,
      category_id char(36) not null,
      primary key (product_id, category_id),
      constraint fk_product_categories_category
          foreign key (category_id) references categories (id)
              on delete cascade,
      constraint fk_product_categories_product
          foreign key (product_id) references products (id)
              on delete cascade
  );
  </code></pre>
  <p>Problem seems to be <code>category_id</code> as if I remove it, the table is created without a problem.</p>
  <p>Category table is also matching the ID;</p>
  <pre><code>CREATE TABLE `categories` (
    `id` char(36) NOT NULL,
    ....
  )
  </code></pre>
  <p>Unfortunately I still get the following error;<code>[HY000][1005] Can't create table product_categories (errno: 150 &quot;Foreign key constraint is incorrectly formed&quot;)</code>. What am I missing here?</p>