我想知道如何设计这个最好的,所以我不重新发明轮子设计问题: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