is stackoverlow database structure available somewhere?
I am facing a situation where I have Table1 with information about something and Table2 with numeric information about Table1 on a 1:n relatioship. Like we have users and answers here on stack overflow for example.
I need to have quick access to the sum of the numeric information (like S.O. has quick access to the user’s reputation sum) and I’m wondering if I add a column on Table1 to store the sum and update it everytime table2 is updated or if I sum all records on table2 every time I need that Info.
S.O. has the same situation and seems to be dealing very well with it. I would like to know which approach do they use.
Yes, we denormalize that into a database field that we update over time. We used to do recalcs (it would drift occasionally) by performing the join / sum, but that hurts – and we didn’t like it being out of sync in the first place. So now, we keep a specific store for reputation changes over time – more direct and accurate history.