title: How to fix foreign key errors in MySQL?
body: <p>I am using Ubuntu on Virtualbox. I’m trying to write my SQL for a database however whenever I create one with a Foreign Key it always returns an error </p>
  
  <blockquote>
    <p>CREATE TABLE Vehicles (Vehicle ID int, Vehicle Type VARCHAR(255), Model VARCHAR(255), Engine Size float, Condition VARCHAR(255), Price float, PRIMARY KEY (Vehicle ID), FOREIGN KEY (Model) REFERENCES Models(Model));</p>
  </blockquote>
  
  <p>Can you help me please? Below are my SQL table statements to create the Database so maybe there is an error in my code?</p>
  
  <pre><code>CREATE TABLE Models (
       Model_ID int NOT NULL,
       Manufacturer VARCHAR(255) NOT NULL,
       Model_name VARCHAR(255) NOT NULL,
       Wheel_Drive_Type VARCHAR(255) NOT NULL,
       PRIMARY KEY (Model_ID)); 
  
  CREATE TABLE Customers (
       Customer_ID int NOT NULL,
       Customer_name VARCHAR(255) NOT NULL,
       Customer_Contact_number VARCHAR(255) NOT NULL,
       Customer_Address VARCHAR(255) NOT NULL,
       Customer_Email VARCHAR(255) NOT NULL,
       PRIMARY KEY (Customer_ID)); 
  
  CREATE TABLE Vehicles (
       Vehicle_ID int NOT NULL,
       Vehicle_Type VARCHAR(255) NOT NULL,
       Model_name VARCHAR(255) NOT NULL,
       Engine_Size float NOT NULL,
       Condition VARCHAR(255) NOT NULL,
       Price float NOT NULL,
       PRIMARY KEY (Vehicle_ID),
       FOREIGN KEY (Model) REFERENCES Models(Model_name)); 
  
  CREATE TABLE Enquiries (
       Enquiry_ID int NOT NULL,
       Vehicle int NOT NULL,
       Customer_ID int NOT NULL,
       Additional_information VARCHAR(255) NOT NULL,
       PRIMARY KEY (Enquiry_ID),
       FOREIGN KEY (Vehicle_ID) REFERENCES Vehicles(Vehicle_ID),
       FOREIGN KEY (Customer_ID) REFERENCES Customers(Customer_ID)); 
  
  CREATE TABLE Sales (
       Sales_ID int NOT NULL,
       Vehicle_ID int NOT NULL,
       Customer_ID int NOT NULL,
       Date_of_sale VARCHAR(255) NOT NULL,
       Sale_Type VARCHAR(255) NOT NULL,
       PRIMARY KEY (Sale_ID),
       FOREIGN KEY (Vehicle_ID) REFERENCES Vehicles(Vehicle_ID),
       FOREIGN KEY (Customer_ID) REFERENCES Customers(Customer_ID)); 
  </code></pre>