Mysql queries dealing with structures of tables and views