日期:2014-05-18  浏览次数:20436 次

急:100分求一个"本周排名"的设计思路...请高人相助...
是这样的,现在要做一个文章管理系统,
其中文章的表结构大概如下:

表名:tableArc
    oid(唯一标志符)
    title(文章标题)  
    udi(文章发布者ID)
              |
              |
    (其它字段)

现在要实现一个功能,就是把一周内(或者最近7天内)被点击查看的文章次数最多的20条记录提出来,进行一个 "本周热门20篇 "的排名...
怎么设计数据库,比较好呢?
请各位大侠帮忙,不胜感激....


------解决方案--------------------
被点击查看的文章次数最多

点击次数直接放在 tableArc 表里就可以阿!
------解决方案--------------------
因为这列是经常要更新的,所以另外建一个表
用oid关联tableArc表
查询的时候关联查询也可以

------解决方案--------------------
简单的说:
——————————————————————————————————————————
文章信息表 tableArc
---------------------------
oid (唯一标志符)
title (文章标题)
uid (文章发布者ID)


阅读记录表 tableRead
---------------------------
nid (唯一标志符)
oid (文章编号)
rid (读者编号)
dates (阅读时间)

——————————————————————————————————————————

create table tableArc (oid int identity(1,1),title varchar(50),uid int)
create table tableRead(nid int identity(1,1),oid int,dates datetime)

select
top 20 TA.*
from
tableArc TA,
(select oid,count(*) as times from tableRead TR where datediff(dd,dates,getdate()) <7 group by oid) VR
where
TA.oid=VR.oid
order by
VR.times desc