why hooks for database firing from all pages...?

Would you please solve my issue…

I have two collection…

student_collection
_id sname mobile1
(system) MATHEW 123456789
(system) TOM 112233445

deposit_collection
_id s_id dep_amount
(system) data from student_collection(_id of MATHEW) 500
(system) data from student_collection(_id of MATHEW) 700
(system) data from student_collection(_id of TOM) 800

I want to show result in table element like these…
sname tot_amount
MATHEW 1200
TOM 800

how to do this… please suggest … thanks in advance