Hello,
Well i can tell you have just a little error in the mysql syntax, I can't tell you where exactly in short, but if you pull the code on codepen.io I could.
All seems ok, just a missing comma or so.
By the way this code is a test and has nothhing to do with WP. In general you create custom tables, it's more convenient to have all in same database.
Regards,