如何获取当天的照片?
我在 MySQL 数据库中有两个表:
照片:
PID - PhotoID [PK],
DateOf - DateTime of uploading,
UID -UserID (owner of the photo)
评级:
WhoUID - UserID who rated,
DateOf - DateTime of rate,
RatingValue - +1 or -1 (positive or negative),
RatingStrength - coefficient (different for each user who vote)
PID - PhotoID, [FK]
真实评级值 = RatingValue * RatingStrength
获得“当天照片”的可能性有哪些“?
规则,例如:
- 当天的照片必须在网站上存在至少 24 小时(自上传时间起)
- 当天的照片必须至少有 10 票
- 当天的照片是具有最大
真实评分值 自上传时间起 24 小时内,
- 当天的新照片不得已存在于
photo_of_day
表
UPD1 中。 10 票意味着 - 每张照片 UPD2 的评分
表中至少有 10 条记录
。是否可以获得准确日期时间的“当天照片”?例如,如何获取“2011-03-11”或“2011-01-25”当天的照片?
I have two tables in MySQL database:
photos:
PID - PhotoID [PK],
DateOf - DateTime of uploading,
UID -UserID (owner of the photo)
ratings:
WhoUID - UserID who rated,
DateOf - DateTime of rate,
RatingValue - +1 or -1 (positive or negative),
RatingStrength - coefficient (different for each user who vote)
PID - PhotoID, [FK]
Real rating value = RatingValue * RatingStrength
What are possibilities to get "Photo of the day"?
Rules, for example:
- photo of the day must be on site at least 24 hours (since uploaded time)
- photo of the day must have at least 10 votes
- photo of the day is the photo with maximum
Real rating value
in 24 hours since uploaded time - new photo of the day must not be already in
photo_of_day
table
UPD1.
10 votes means - at least 10 records in table ratings
for each photo
UPD2. Is it possible to get 'photo of the day' for exact datetime? For example, how can I get photo of the day for '2011-03-11', or '2011-01-25' ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
此查询可能需要一段时间,因此不要在每个页面请求上都执行此操作是有意义的。您可以通过在午夜运行一次的脚本将结果存储在
photo_of_day
中。This query probably takes a while, so it makes sense to not do this on every page request. You store the result in
photo_of_day
once by a script that runs once at midnight.像这样的东西。我不确定“当天的新照片不得已在 photo_of_day 表中”,但试试这个 -
Something like this. I'm not sure about 'new photo of the day must not be already in photo_of_day table', but try this one -