I am just curious, have you thought about utilizing the Class toggle described here, Set Table Row Background Color with Dynamic Value for the color selections in your table?
As far as the database creation goes, it looks like you might have solved that. In the future, I would recommend using mysql workbench, it contains a modal option that allows you to create databases and their relationships visually. I have found it to be very easy to do and saves me lots of time.