我想知道如何設計這個最好的,所以我不重新發明輪子設計問題:Symfony2中,doctrine2,MySQL數據庫
我有一個評分實體:
/**
* 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;
其中類型是評分類型,例如「file.quality」或「file.story」,用於共享視頻。
現在我想打開視頻的詳細信息頁面,並顯示總評分(所有用戶的平均值....也有評分,這些評分與用戶無關,但來自其他地方....像
IMDB(互聯網電影數據庫)的收視率。我在想添加一個CompleteRating
實體,其中我省的平均得分直接更新,只要用戶增加了一個新的投票進入Rating
實體。也許通過symfony2中的聽衆類
這是最好的設計方式嗎?你會如何處理這個最好的?
感謝man,怎麼樣3.在評分表中添加一行IMDB評分(非用戶評分),但是用0或null作爲用戶ID?我試過它雖然與doctrine2,它給了我一個錯誤,因爲用戶不存在...所以也許這是另一種解決方法?....也有不同種類的收視率在同一收視表:「rating_quality」 ,「rating_sound」....等等......我也計劃在將來把評價標準提供給像「rating_user_credibilty」等用戶。 – Confidence 2012-03-30 12:30:17
/** @ORM \ Column(name =「user_id」,nullable = true)* /將照顧用戶不存在的問題。 – Cerad 2012-03-30 14:24:31