您好,欢迎访问一九零五行业门户网

点评/投票/心情类的功能什么机制限制会员只能投一次最省事?

一些好像点评的系统,比如:文章下面,显示:好评/差评  这样的按钮
也就是像csdn论坛的文章页面的...
对我有用[0] 丢个板砖[0]
个人理解:
点一下经由ajax/jq这类发送去php操作mysql, 把好评/差评的字段+1
但是,一般这类的东,都是限制ip,甚至是只限cookie...
如果好评/差评的数据确有需要非常准确无水份
我是想用会员登入后才能点评(投票好差)的
那mysql 是否需要建议一个独立的点评表?
还有数据架构有什么比较好的方法,可以限制会员只能投一次?
请教一下各位,有什么好的建议?
回复讨论(解决方案) 实在方法有很多,完全可以建立一个独立的表。记录哪一个帖子,哪一个会员,投了多少票。什么时间投的。ip什么的
下次他在投的时候,根据会员id,帖子id,不就能找到投票状态了么?
建表是必须的,还不止一张
因为你还可能有 xx 关注了 xx、xx 是 xx 的好友等一系列的需求
需要综合考量
你现在思索的的是 sns 网站的核心(或称基础)
参考下:
投票信息表:
create table `votes` ( `id` int(11) not null auto_increment, `ip` varchar(250) not null, ·uid· int(11) not null, `vid` int(11) not null, `fstcreate` timestamp not null default current_timestamp on update current_timestamp, primary key (`id`) ) engine=myisam auto_increment=1 default charset=utf8
文章表
create table `article` ( `id` int(11) not null auto_increment, `article_title` varchar(250) not null, `article_type` int(11) not null, `article_content` longtext not null, `article_author` varchar(50) not null, `article_click_count` int(11) not null default '0', `status` int(11) not null default '0', `likes` int(11) default '0', `unlikes` int(11) default '0', `fstcreate` timestamp not null default current_timestamp on update current_timestamp, `lastmodify` datetime default null, primary key (`id`), fulltext key `fulltext_article_title` (`article_title`,`article_content`,`key_words`) ) engine=myisam auto_increment=119 default charset=utf8 checksum=1 delay_key_write=1 row_format=dynamic comment='文章表'
如果限定登陆用户才可以投票,这样只要控制用户id和投票的主题id即可。
同一篇同一?用?只能投一次就可以了。
表可以
id
aid          id
mid         用?id
addtime
select count(*) from table where aid=? and mid=? 判?是否=1 定用?是否可以再投。
来看的话不能单靠cookie或者ip来限制
必须使用到sql
但有个效能问题要请教
以下两个方案哪个好?
a. 好评/差评放在文章表的栏位
每次好评,除了加入一张独立表格,同时在文章的好评/差评的栏位+1
b. 建立一张独立表单,记录好评/差评的动作
每一次好评/差评,都新增一条记录
comment表
id (自动)
uid 用户id
tid 文章id(topic id)
vote  好评/差评(1/0)
文章 tid=90
差一差有多少
好评数:select count(*) from `comment` where `tid`='90'  and `vote` = '1'  
差评数:select count(*) from `comment` where `tid`='90'  and `vote` = '1'
犹疑的地方:
方案a,每次都去+1....topic 内容肯定比 comment 数据空间大,感觉会不会更消耗?
但是记录在topic,在文章列表中,select 时肯定比较省资源,因为只select topic一张单,也不用计算comment 表有多少与 tid 有关的
方案b, 在用不到好评差评时,topic操作会较少,但要select时...好像每次都要count(*) 计算会唔会更费资源?  如果5万篇文章 每篇平均下来有200个好/差评,这样comment已经有1000万条数据?  如果更多呢?   或者在几百万的数据中 不停 count(*) 会不会已经负担不住? 因为主题列表呢?
在此先不讨论cache问题,单纯以这两个 sql方案哪个比较低消耗资源一点?
其它类似信息

推荐信息