I find the best way to insure a unqiue db name is to base it on your domain name. Forexample: wp_domain, temp_domain, etc.
I use the following convension for naming my DBs, always unique:
- All DB hostnames are under db.domain.com: main.db.domain.com
- All DBs are named the same names as the hostname, w/out the extension: main_db_domain
(I also have a convension for usernames, too, but for obvious releasons I won't post that. )