I had something set up just over a year ago (but I will have to re-learn how to do it, when I finally launch this thing I'm building), when I was seeing if it all was gonna work... and it did work. Worked really well.. but I didn't have AwareIM connecting to the remote Database itself. I had a local database (on the server running AwareIM), MySQL, and the remote database was MySQL.
They spoke to and updated each other using some Federated Tables and SSH tunneling. It worked fine.
I used the Federated Tables in combination with some triggers and scheduling in the Local database, and also on the remote one, so that if and when the SSH connection was down, the AwareIM server would keep operating and the users would be oblivious to a temporary connection issue.