社交网络网站的好友表
现在我正在一个社交网络网站上工作,我已经为这个网站构建了朋友表,但在继续之前我需要一些建议。
我有一个用户表,其中 user_id 是主字段。
因此,对于朋友,我创建了一个朋友表,其中包含
friend1
、friend2
、is_active
等字段,当 user1 向 user2 发送好友请求时,我实际上做了什么那一刻我将两行插入朋友表中,就像
1- friend1->user1,friend2->user2,inactive
2- friend1->user2,friend2->user1,inactive
这样,当有人接受朋友请求时,我将这两行设置为活动状态。
每当一个用户阻止另一个用户时,我就根据需要创建了这两个条目,然后轻松地使属于该用户的相应行将处于非活动状态。
如果用户删除该用户,那么那时我会删除这两个条目。
因此,我需要一些有关此问题的建议,请帮助我尽快解决此问题。
我需要知道是否有其他方法比这更优化并给出正确的结果。
Now i am working on a social network website and i already built the friends table for this website but i need some suggestion before i moved forward.
I have a user table where user_id is the primary field.
So for friends i made a friends table with fields like
friend1
,friend2
,is_active
what i do actually when user1 send a friend request to user2 then at that moment i insert the two rows into the friends table like
1- friend1->user1,friend2->user2,inactive
2- friend1->user2,friend2->user1,inactive
So when somebody accept the friend request at that moment i made the both rows as active.
I made this two entries as i want whenever one user block another then easily made that corresponding row belongs to that user will be inactive.
And if a user remove the user then at that time i delete the both entries.
So please i need some suggestion regarding this please help me out to solve this asap.
I need to know is there any other way which will be more optimized than this and giving proper result.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为
朋友表
使用
User_id1、User_id2 和 Rleationship_id
更容易,在第一列和第二列上建立索引。
关系 ID 将是 1 - id1 请求、2- id2 请求、3 - 朋友、4- id1 被阻止、5 - id2 被阻止...
只是一个想法。
I think that
Friends_table
with
User_id1, User_id2 and Rleationship_id
is easier, index on both first and second column.
relationship id will be 1 - id1 request, 2- id2 request, 3 - friends, 4- id1 blocked, 5 - id2 blocked...
just an idea.