Hi,
no answer - you have to find out yourself... First of all, you are not going to use
http://somewhere.com/database or anything like that, but rather the mysql_connect data in your script will name a specific server (and perhaps a specific port) rather than the default localhost.
If both domains are running on the same server group / hosting company, there should be no problems. If they are different, it deends on the security policy of the database server whether you can connect directly.
If it does not work, you will probably have to use some proxy scripting. See the latest tutorials to find out more about this topic
Musicman