Multiple database using hooks

Hi

I wanted to update 2 database using hooks. Can you help me out with the code.

Question is: Its a leave management application. I have entitlement database and a availed database. I need to find 3 things. One is Entitlement which I can pull from the database. No problems. Availed leave is also not a problem.

  1. How will I find the leave balance, which should Entitlement - sum of Availed
  2. Unable to do the sum up the the particular field of the employee
  3. Also read some article that we can create Hooks and update it in both the database. Unable to find the code. How to do it.

Please help me. I am nearing my deliverable dates