When I attempt to run the CREATE TABLE statements you posted, I get a ton of errors. Please create an empty database, run the code yourself, and fix all errors, then post the corrected code.
I am happy to spend my time to fix problems you are experiencing, but I refuse to waste my time on fixing simple things like foreign keys to other tables that you can easily check and remove yourself.