this sounds a lot like indexing that the block explorers do. so you may want to check out the source code of some of the open source block explorers to see how they are doing that like insight
https://github.com/bitpay/insight maybe this can clarify your question so others can help you more.
and you keep giving this example:
Public key -- balance?
72e0d74f683d5ca6a5ae59b2db39be2dda20bddd4272895d4ee39f323cf9c113 -- 1.111111 BTC
but 72e... is not a public key! you seem to be doing something wrong so far to this point in your code too.