FriendShip数据库结构 [英] FriendShip Database Structure

查看:104
本文介绍了FriendShip数据库结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个社交网站.
其中具有FriendShip数据库结构.

我有2张桌子.

1)UserMst->其中包含用户信息
UserID(Int),
FName(Varchar(20)),
LName(Varchar(20)),
TotFriendCount(Int)

2)FriendMst->其中包含用户和朋友的信息
FriendID(Int),
UserID(Int),
FriendID(Int),
ApprovalStatus(Bit),-Status为true时,则都是朋友
ApprovalDate(Date),
TotMutualFriendCount(Int)


现在,当FriendMst.ApprovalStatus更改为"True"时,我必须更新
"UserMst.TotFriendCount"和"FriendMst.TotMutualFriendCount"字段.

我正在尝试很多事情来做到这一点.但那都是非常漫长且昂贵的过程.
我正在寻找一个查询来执行此操作...
有人可以帮助我>

I am developing a Social Networking site.
Which has FriendShip Database Strucure.

I have 2 table.

1) UserMst -> which has containt user information
UserID(Int),
FName(Varchar(20)),
LName(Varchar(20)),
TotFriendCount(Int)

2) FriendMst -> which has containt user and friends information
FriendID(Int),
UserID(Int),
FriendID(Int),
ApprovalStatus(Bit), --Status when true, then both are friends
ApprovalDate(Date),
TotMutualFriendCount(Int)


Now, When FriendMst.ApprovalStatus change to "True", then i have to update
"UserMst.TotFriendCount" and "FriendMst.TotMutualFriendCount" fields.

I am trying lots of things to do this. but that all is very long and expensive process.
I am looking for one single query to do this...
some one can help me>

推荐答案

使用触发器进行更新.记住,他们可能想取消交友.
Use a trigger to do the update. Remember they might want to unfriend.


这篇关于FriendShip数据库结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆