I am wondering how to design this best, so i do not re-invent the wheel
i have a rating Entity:
/**
* Type of the read of this comment,for example quality
*
* @ORM\Column(type="string")
*/
protected $type;
/** @ORM\Column(type="datetime") */
protected $created;
/** @ORM\Column(type="integer") */
protected $thread;
/**
*
*
* @ORM\ManyToOne(targetEntity="User")
*/
private $user;
/**
* @ORM\Column(type="decimal", scale=2)
*/
protected $value;
where the type, is the type of rating, for example for "file.quality" or "file.story", for shared videos.
now i want to open the details page for the video, and have the total rating showing (as average of all users....also there are ratings, which have nothing to do with users, but coming from other places ....like IMDB (internet movie database) ratings.
i am thinking of adding a CompleteRating entity, where i save the average rating and update it directly, whenever a user adds a new vote into Rating Entity. Maybe through a listener class in symfony2.
is this the best design way? how would you handle this best?