"Jamie Tufnell" <diesql@googlemail.com> writes:
> item_count int -- this is derived from (select count(*) from items
> where group_id = id)
> ...
> item_count would be updated by insert/update/delete triggers on the
> items table, hopefully that would ensure it is always correct?
> I'm wondering is what I'm trying to do here pretty standard and are
> there any gotchas I should be aware of?
Concurrent updates to the items table make this much harder than
it might first appear. If you're willing to serialize all your updating
transactions then you can make it work, but ...
regards, tom lane