so there you go, you have some “categories" and some objects. for simplicity let's assume one object can be in only one category.
if this is too theoretical for you – let's assume these are “mails in folders", “photos in galleries", “posts in categories" or “auctions in categories on ebay".
everything clear? now, let's assume you want to know how many “objects" are in given “category".
most basic way to do it is:
select count(*) from objects where category = some_category;
but this method is far from optimal. now, we'll learn how to do it better.
one warning for those of you who read the rss feed – if you say “yeah, i know the code, it's simple" – ask yourself – is your code deadlock-proof?
Continue reading objects in categories – counters with triggers