After rereading my explanation about the article counts, it still seems a bit vague. Let me try again:
One a first pass through the database all categories and their mutual relations are collected.
On a second pass a list is compiled for each article of all categories that are named in the article and of their supercategories, duplicates are removed. Then all categories in the list have their counter incremented by one.
Erik Zachte
wikipedia-l@lists.wikimedia.org