There is not a simple answer to this task.
You have would have to use a
Query to check the dictionary of the database for the table in question.
Therefor You need a Database connection. Which itself is in question.
So You have to start with a connection to "Your" database.
If this succeeds, speaking "connect succeeds", You probably like to check, if the database retrieved by given name is the one, You are looking for.
Query for known tables, check Your own privileges.
If everything is fine, start with your datamodel commands above.
some dictionary links:
Code:
SELECT table_name FROM INFORMATION_SCHEMA.TABLES
WHERE table_schema = 'db_name'
[AND table_name LIKE 'wild']
SHOW TABLES
FROM db_name
[LIKE 'wild']
http://dev.mysql.com/doc/refman/5.0/...les-table.html