0

I have a table named Companies where there is a Rating column. Company has many reviews and which has its Rating column.

Companies.Rating = Average of its Reviews' Ratings. My question: It'll be easier for me Companies.Rating to be computed instead of it to be updated when Company review is deleted, inserted, updated etc.

Will it slow down the app. seriously ? P.S. each company will have about 300 reviews.(maximum)

levi
  • 3,451
  • 6
  • 50
  • 86
  • 2
    Compute it until you encounter an actual performance issue. – Andomar Mar 12 '13 at 18:24
  • Agree with Andomar. 300 reviews and an aggregate shouldn't be a big deal. – granadaCoder Mar 12 '13 at 18:40
  • How are you going to compute it? A [computed column](http://msdn.microsoft.com/en-us/library/ms191250(v=sql.105).aspx) can only reference columns in the same table, so you can't put a computed column on the `Companies` table to show a value calculated from the `Reviews` table (if that was your idea, it's a bit unclear). You could use a [function](http://stackoverflow.com/questions/2769007/formula-for-computed-column-based-on-different-tables-column) but a view might be a better (simpler) idea here. – Pondlife Mar 12 '13 at 21:14
  • Yes, @Pondlife I've created a function which returns average rating for a single company. What do mean by creating view? – levi Mar 12 '13 at 22:00

0 Answers0