数据库存储用户信息怎么实现 比如说有n个用户 每个用户都有关注的人的数据,粉丝的数据和用赞过的图片的数据,因为每一个用户的粉丝数,关注的人数或赞过的图片等数据的个数不一样,这样的话应该如何建立数据库,求解答,好蒙啊!大神快救救我 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 因为我没有系统的学过数据库,能否告知怎样建立多对多的中间表怎么建立吗比方说用户表user表,主键user_id,粉丝表 fan表,主键fan_id那么用户与粉丝多对多表建立为user_fans_ref(id bigint not null auto_increment primay key, user_id bigint not null, fan_id bigint not null, create_time datetime not null) engine =innodb comment '用户粉丝表'; 因为我没有系统的学过数据库,能否告知怎样建立多对多的中间表怎么建立吗比方说用户表user表,主键user_id,粉丝表 fan表,主键fan_id那么用户与粉丝多对多表建立为:create table user_fans_ref(id bigint not null auto_increment primay key, user_id bigint not null, fan_id bigint not null, create_time datetime not null) engine =innodb comment '用户粉丝表'; 存储粉丝点赞信息到数据库//粉丝登陆关注你信息 //显示登录名 lbeUserName.Text = Session["userName"].ToString(); addPlaySum(); //调用自定义方法增加评论的点击率 //增加点击率和用户积分 public void addPlaySum() { //创建SQL语句,增加评论的点击率 string sql = "update videoInfo set playSum=playSum+1,monthSum=monthSum+1 where id=" + Request["id"]; operateData.execSql(sql); //创建SQL语句,查询粉丝会员名 string sqlSel = "select userName from videoInfo where id=" + Request["id"]; //获取会员名 string userName = operateData.getTier(sqlSel); //创建SQL语句,增加用户的积分 string sqlUpd = " update userInfo set sumMark=sumMark+1 where userName='" + userName + "'";//修改数据库点击数自加1 //执行SQL语句 operateData.execSql(sqlUpd); } //防止同一个粉丝重复点击 protected void addPoll(string sqlUpd, string videoId) { //获取当前用户的ip string userIP = Request.UserHostAddress.ToString(); //编写SQL查询用户ip是否已对该粉丝 string sqlSel = "select * from videoPoll where ip='" + userIP + "' and videoId='" + videoId + "'"; if (!(operateData.getCount(sqlSel) > 0)) { //如果未参与就同意参与 operateData.execSql(sqlUpd); //编写SQL语句记录用户的ip和评论id string sqlIns = "insert videoPoll values('" + userIP + "'," + videoId + ")"; operateData.execSql(sqlIns); RegisterStartupScript("", "<script>alert('成功!')</script>"); } else { RegisterStartupScript("", "<script>alert('一个内容只可以投一次')</script>"); }//CodeGo.net/ } //顶该评论内容 protected void imgbtnD_Click(object sender, ImageClickEventArgs e) { //编写SQL语句更新顶评论内容 string sqlUpd = "update videoInfo set flower=flower+1 where id=" + Request["id"]; //调用自定义方法防止重复ip顶踩 addPoll(sqlUpd, Request["id"].ToString()); //重新显示评论详细信息 videoInfo(); } //踩该评论内容 protected void imgbtnC_Click(object sender, ImageClickEventArgs e) { string sqlUpd = "update videoInfo set tile=tile+1 where id=" + Request["id"]; addPoll(sqlUpd, Request["id"].ToString()); videoInfo(); }//尊敬的客户朋友这里都是修改数据库的数据,按照修改字段设置数据库信息,自己随意更改添加了(修改图片略) mysql 创建 触发器遇到的问题 mysql乱码问题 自动执行文件? 根据ip地址对应出地址 请问,win下 Postgresql8.3如何让非本机用户访问? mysqldumpslow sql语句分析 Tomcat和Mysql的问题,很奇怪。。。。。。 请教各位,有一数据表中的字段有部分为中文,偶现在要把所有中文的替换掉怎么办? ?-?-????如何用ODBC建立odbc数据源? 菜鸟求助多表查询问题。 dump文件怎么附加 如何查询字段中多行数据的首列?
那么用户与粉丝多对多表建立为
user_fans_ref(
id bigint not null auto_increment primay key,
user_id bigint not null,
fan_id bigint not null,
create_time datetime not null
) engine =innodb comment '用户粉丝表';
那么用户与粉丝多对多表建立为:
create table user_fans_ref(
id bigint not null auto_increment primay key,
user_id bigint not null,
fan_id bigint not null,
create_time datetime not null
) engine =innodb comment '用户粉丝表';
//粉丝登陆关注你信息
//显示登录名
lbeUserName.Text = Session["userName"].ToString();
addPlaySum(); //调用自定义方法增加评论的点击率
//增加点击率和用户积分
public void addPlaySum()
{
//创建SQL语句,增加评论的点击率
string sql = "update videoInfo set playSum=playSum+1,monthSum=monthSum+1 where id=" + Request["id"];
operateData.execSql(sql);
//创建SQL语句,查询粉丝会员名
string sqlSel = "select userName from videoInfo where id=" + Request["id"];
//获取会员名
string userName = operateData.getTier(sqlSel);
//创建SQL语句,增加用户的积分
string sqlUpd = " update userInfo set sumMark=sumMark+1 where userName='" + userName + "'";//修改数据库点击数自加1
//执行SQL语句
operateData.execSql(sqlUpd);
}
//防止同一个粉丝重复点击
protected void addPoll(string sqlUpd, string videoId)
{
//获取当前用户的ip
string userIP = Request.UserHostAddress.ToString();
//编写SQL查询用户ip是否已对该粉丝
string sqlSel = "select * from videoPoll where ip='" + userIP + "' and videoId='" + videoId + "'";
if (!(operateData.getCount(sqlSel) > 0))
{
//如果未参与就同意参与
operateData.execSql(sqlUpd);
//编写SQL语句记录用户的ip和评论id
string sqlIns = "insert videoPoll values('" + userIP + "'," + videoId + ")";
operateData.execSql(sqlIns);
RegisterStartupScript("", "<script>alert('成功!')</script>");
}
else
{
RegisterStartupScript("", "<script>alert('一个内容只可以投一次')</script>");
}//CodeGo.net/
}
//顶该评论内容
protected void imgbtnD_Click(object sender, ImageClickEventArgs e)
{
//编写SQL语句更新顶评论内容
string sqlUpd = "update videoInfo set flower=flower+1 where id=" + Request["id"];
//调用自定义方法防止重复ip顶踩
addPoll(sqlUpd, Request["id"].ToString());
//重新显示评论详细信息
videoInfo();
}
//踩该评论内容
protected void imgbtnC_Click(object sender, ImageClickEventArgs e)
{ string sqlUpd = "update videoInfo set tile=tile+1 where id=" + Request["id"];
addPoll(sqlUpd, Request["id"].ToString());
videoInfo();
}
//尊敬的客户朋友这里都是修改数据库的数据,按照修改字段设置数据库信息,自己随意更改添加了(修改图片略)