Improve validation of database and table name