Foreign Keys and Data Import
You have several choices. You can either create the tables without the constraints &amp; add them afterwards, or create the tables with the foreign keys &amp; them import the data with foreign key checks disabled - simply run SET FOREIGN_KEY_CHECKS=0; in your mysql session to temporarily disable them.

For example: 

mysql&gt; insert into favourite values( 1,1);
ERROR 1452 (23000): Cannot add or update a child row: a foreign key constraint fails (`tmp`.`favourite`, CONSTRAINT `favourite_ibfk_1` FOREIGN KEY (`item_id`) REFERENCES `item` (`item_id`))
mysql&gt; SET FOREIGN_KEY_CHECKS=0;
Query OK, 0 rows affected (0.00 sec)

mysql&gt; insert into favourite values( 1,1);
Query OK, 1 row affected (0.00 sec)