title: Syntax error creating a foreign key
body: <p>I am trying to create the following tables design but I am getting this error below how can I set the foreign key for the <code>stops</code> table  in the <code>arrivaltimes</code> table?</p>
  
  <blockquote>
    <p>1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FOREIGN KEY REFERENCES stops(stop_id) )' at line 4 </p>
  </blockquote>
  
  <pre><code>stt.execute("CREATE TABLE IF NOT EXISTS stops"
          + "(stop_id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, "
          + " name varchar(30) NOT NULL, " + " route INT(11) NOT NULL, "
          + " lat double(10,6) NOT NULL, "
          + " longi double(10,6)NOT NULL) ");
  
  stt.execute("CREATE TABLE IF NOT EXISTS arrivaltimes(id INT(11) NOT NULL PRIMARY KEY,"
          + " weekday VARCHAR(20) NOT NULL,"
          + "arrivaltime time NOT NULL,"
          + " stop_id INT FOREIGN KEY REFERENCES stops(stop_id) )" );
  </code></pre>