title: MySQL Foreign Key, Can't create table (errno: 150)
body: <p>I am trying to build the database and tables for my system. But I found that if I don't add the foreign key in the codes. There is no error. I've used many method try to make the codes works, but it still have error.</p>
  
  <p>I am using MySQL 5.5.31, and the codes here:
      CREATE DATABASE TOS; </p>
  
  <pre><code>DROP TABLE TOS.USER CASCADE;
  DROP TABLE TOS.BILL_HEADER CASCADE;
  DROP TABLE TOS.TOY CASCADE;
  
  
  CREATE TABLE TOS.USER
  (User Char(8),
  Name Char(10),
  Type Char(1),
  Password Char(12),
  PRIMARY KEY(User));
  
  CREATE TABLE TOS.BILL_HEADER
  (Bill_No Char(10),
  CTime DateTime,
  No_Of INTEGER,
  Cus_No Char(5),
  DTime DateTime,
  PRIMARY KEY(Bill_No));
  
  CREATE TABLE TOS.TOY
  (Toy_Id Char(10),
  FullN Char(50),
  ShortN Char(20),
  Descrip Char(20),
  Price DECIMAL,
  Avail Char(1),
  Cat Char(1),
  PRIMARY KEY(Toy_Id));
  
  CREATE TABLE TOS.BILL_ITEM
  (Bill_No Char(10),
  BSeq_No INTEGER,
  Toy_Id Char(10),
  OTime DateTime,
  Quan INT,
  DCondition Char(1),
  PRIMARY KEY(Bill_No,BSeq_No),
  FOREIGN KEY(Bill_No) REFERENCES TOS.Bill_Header(Bill_No),
  FOREIGN KEY(Toy_Id) REFERENCES TOS.TOY(Toy_Id));
  </code></pre>
  
  <p>Error:</p>
  
  <blockquote>
    <h1>1005 - Can't create table 'TOS.BILL_ITEM' (errno: 150)</h1>
  </blockquote>
  
  <p>Any help would be greatly appreciated.</p>