Good work.


Caching columns is pretty common practice. However, it does mean more work to maintain data integrity.

If you're using MySQL 5, you can use table triggers (basically a mini stored procedure that can be hooked on to various events like insert or delete) to automatically update the cache columns, thus minimising the amount of code you have to write and lessening the chance of getting the counts out of sync.