目前当前功能如下:
用户好友
friend_iD | friend_One | friend_Two | Role |
friend_iD : int(11) AUTO_INCREMENT.
friend_One: int(11).
friend_Two: int(11).
Role: VARCHAR(5).
一旦我第一次注册,以下内容将被插入到 userFriends 表中(在本示例中,我自己将使用 iD 2)。
friend_iD | friend_One | friend_Two | Role |
15 NULL NULL me
如果我正在访问 ID 为 1 的 John 的个人资料,并且单击[关注]按钮,则以下内容将插入到 userFriends 表列中。
friend_iD | friend_One | friend_Two | Role |
20 2 1 fri
iD 1 : John
iD 2 : Gabby(Myself)
现在这意味着我是 friend _iD 为 2 的一个正在关注 iD 为 1 的 John。
Gabby[2] > John[1]
<强>1。对于关注系统来说,这是一个很好的表结构吗?
<强>2。如果不是,我可以改进什么或者有机会让它更快或者 更好,我怀疑这样的性能会有任何问题 简单的功能。
最佳答案
Once I first register, the following will be inserted into the userFriends table
(In this example I will be using iD 2 for myself).
您需要为用户创建一个单独的表,例如
users
user_id | username | password | active | etc (email and another info)
然后您需要像您的设计一样创建follow
表
follow
friend_id | follower_user_id | followed_user_id
我不知道角色字段在您的设计中有何用途。如果需要的话添加即可
关于php - 好友关注/取消关注表结构#MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17437650/