Php Friend Follow/Unfollow表结构#MySQL

Php Friend Follow/Unfollow表结构#MySQL,php,mysql,pdo,Php,Mysql,Pdo,目前,该功能如下所示: 用户朋友 在我第一次注册之后,以下内容将被插入到userFriends表中(在本例中,我将为自己使用iD 2) 如果我正在访问John的个人资料,其iD为1,并单击[Follow]按钮,则以下内容将插入到userFriends表列中 friend_iD | friend_One | friend_Two | Role | 20 2 1 fri iD 1 : John iD 2 : Gabby(Myself

目前,该功能如下所示:

用户朋友

在我第一次注册之后,以下内容将被插入到userFriends表中(在本例中,我将为自己使用iD 2)

如果我正在访问John的个人资料,其iD为1,并单击[Follow]按钮,则以下内容将插入到userFriends表列中

friend_iD | friend_One | friend_Two | Role |
    20            2           1         fri

iD 1 : John
iD 2 : Gabby(Myself)
现在这意味着我是朋友,一个iD为2的人正在跟踪iD为1的约翰

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
friend_id | follower_user_id | followed_user_id

我不明白角色场在你的设计中有什么用。如果需要的话就添加它

这就是我目前拥有的,我只是想看看是否有更好的方法来拥有一个更注重性能的follow/unfollow表结构。我认为表结构不是问题,如果你有性能问题,也许你可以为mysql做性能调整,创建索引,查询优化,等等当用户取消跟踪时我们应该做什么。从表中删除行或需要维护该行的状态?
users
user_id | username | password | active | etc (email and another info)
follow
friend_id | follower_user_id | followed_user_id