I am working on user reviews with this columns:
Each column can be number from 1-5. My question is how to calculate average grade for each column with out calling all reviews from database and calculating it every time.
So I was thinking to put in product table:
and than do: average= communication_sum_of_grades / communication_number_of_reviews
My question is if this is right approach?
If there are large number of records
and query for average reviews are very frequent
then your method will be efficient
because in this case writing will be a touch heavy
but reading will be very fast
. But in case the query for average reviews is not that frequent then you may go for the triditional method of fetching all rows and finding avarage.
hope it helps :)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.