I have a member-member join table. The schema is member_id, friend_id, is_active. I want to create a list of connections between people who are friends of friends. I am not sure how to resolve this issue, not to mention the semi-optimized form.
In the above table, it works so that member_id and friend_id are essentially the same in another table. On my system, these identifiers are usually called member_id, with the exception of this table. For example, suppose my member_id is 21. My number can be in an infinite number of other lines, like either member_id or friend_id, or based on who originally initiated the actual friendship request, and I don’t need redundant data, I would have cheated ranks to basically do the same.
I would like to have a query where I can not only set the degree level (think LinkedIn), but I can also set how many common friends a single person can display (think on Facebook). Here x is the is_active column that I mentioned earlier. This column can be 0 or 1. This is a simple tinyint column that acts as an on / off switch. Any friendships with 1 will be active friendships, while 0 is expecting. I need to base this request on my active friends and their active friends and so on. Where none of my friends' active friends are my active friends.
How can I build such a query (even if I can’t show the separation level and get only the mutual count)? Right now, I can come up with something, but it includes a query after requesting some nested in loops, and yes, I just can’t imagine that this is good for the overall performance or performance of my servers over time.
chris source
share