Friends System with PHP

Asked

Viewed 302 times

0

Hello, I would like to know how to create a system of friendships for my application, facebook style. I’m not making a social network, but I need to implement this system.

I have a table of users where I store data as id and username of registered people.

I saw some solutions out there, that said to create a table "friends", and in this table record the id of the requester, and the id of the requested, then when the user logs in, the system would load his friends from this table. But performatively, in case the application becomes too large, this solution seems to me to be impractical. It would take a long time to load the friends of a particular user, if the table had, for example, 50,000 records.

Does anyone have any idea what I can do to create this system in an efficient way?

  • So man, I want something different than what’s in this question, he used a friends table, I want a way to create this system.

1 answer

0


The form you cited is the most efficient one using a relational database. If you have problems with database scalability, hire a service to do it for you in an automated way. A much used and that I recommend is the RDS from Amazon.

Facebook itself uses a non-relational model to make this type of data transaction, if it suits you, also search for Mongodb and see if he meets your needs. The learning curve is small, and you can implement it in just one part of your system (in your case, interactions between users).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.