Hi there, currently there is a
mapping(uint256=>mapping(string=>uint256)) _idLocBal; data structure stroing the balance for an id at a location in a smart contract. And it would be usesful to be able to do simple summary statistics such as given a location, what would the average balance be, etc. It would be redundant and costly to create different mappings and run for loops on chain to get such numbers.
This is making me wonder if the best practice of maintaining such a database is to use an off-chain database in a centralized server. The database is updated constantly by listening to relevant events on the
_idLocBal mapping above.
Is this how it is done for other DApps? Many thanks in advance if any practical example can be pointed to.