I'm trying to figure how I would start setting up the Bayesian rating system in MYSQL. I am not using a 5 star rating, but something similar. Mine will be a 5 volume bar.
This is for my album page. Instead of users rating the album, they will rate the songs that will be averaged to become the album rating.
$songsum
$songavg
$numofrated
$totalsongs
$albumrating
$songsum / $numofrated = $songavg
$songavg * ($numofrated / $totalsongs) = $albumrating
The another page (artist page) will also be rated.
$avg_num_votes = 18; // Average number of votes in all products
$avg_rating = 3.7; // Average rating for all products
$this_num_votes = 6; // Number of votes for this product
$this_rating = 4; // Rating for this product
$bayesian_rating =
( ($avg_num_votes * $avg_rating) + ($this_num_votes * this_rating) )
/ ($avg_num_votes + $this_num_votes);
How should I start setting this up? Should $this_rating
be in the same table as the album?
Additional information
- Tables in MYSQL: Albums, Songs, Genres, Solo, Group
- Already has foreign keys linkage