I have a database of users who can have any number of friends. Sometimes, I just need the total number of friends (without need for whom they are). From a practical and efficiency standpoint, would it be wise to have a running counter of friends as a column for each user? This is in contrast to running a query each time on a friends' database to count the number of rows returned. Is there any standard for this?
If the query is run very often, it's fine to denormalize. But, for better guaranteed consistency, you can put the counter updates in insert/delete triggers on friends relationship table, rather than in your server-side code.