Better logic for creating database tables if they don't exist in sql