Bug: Above error occurs when rebuilding a database from the SQL script.
Reason: This error usually occurs when the table being created cannot fulfill a foreign key constraint. This often happens when importing from a previously exported database script as database export tools like SQL Yog export tables in alphabetical order of their names, irrespective of their inter-dependencies.
Solution: Recreate the DB script in “Turn off foreign key” mode. If this is not possible, in the current script, run the create query for independent tables first, followed by ones dependent on them, and so on.