Mysql 计算友谊的程度
我创建了以下用于存储用户朋友的数据模型- 数据库-MySQL 选项1为此使用MySQL OQGraph引擎,但这需要 Mysql的特殊构建 选项2使用MySQL中的存储过程执行BFS 你能在这里提出一些比我已经说过的更多的算法/模型吗 谢谢Mysql 计算友谊的程度,mysql,algorithm,data-structures,social-networking,Mysql,Algorithm,Data Structures,Social Networking,我创建了以下用于存储用户朋友的数据模型- 数据库-MySQL 选项1为此使用MySQL OQGraph引擎,但这需要 Mysql的特殊构建 选项2使用MySQL中的存储过程执行BFS 你能在这里提出一些比我已经说过的更多的算法/模型吗 谢谢 tbl_user [ user_id - pk ] tbl_user_friend [ inviter_id - fk, friend_id - fk, status - 1/2/3 ] status = 2 => friend ,
tbl_user [ user_id - pk ]
tbl_user_friend [ inviter_id - fk, friend_id - fk, status - 1/2/3 ]
status = 2 => friend , = 1 => invite ...
select friend_id from tbl_user_friend where inviter_id = <logged_in_id> and status = 2
UNION
select inviter_id from tbl_user_friend where friend_id = <logged_in_id> and status = 2
Convert above data into Graph and do BFS search.
Level of a node in BFS traversal will be its degree of connection.