Database manager

@isupeene Working Database manager that is tested. Still needs contracts.

Note: Need to run database_clear.sql and then database_setup.sql on our DB before submitting.
Well I was using temporary tables. but MySql has issues when trying to UNION ALL temporary tables so that's why I create real tables now. Probably could make temp tables work with enough effort but this way just worked.