Friends System with PHP [duplicate]

0

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

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

I saw some solutions out there that said to create a "friends" table, and in that table write the id of the requestor, and the id of the requested, hence when the user logged in, the system would load his friends from this table. But in performatic terms, in case the application gets very large, this solution seems to me to be very unfeasible. It would take a long time to load the friends of a given user, if the table had, for example, 50,000 records.

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

    
asked by anonymous 09.04.2016 / 19:23

1 answer

0

The form you cited is most efficient using a relational database. If you have trouble scaling the database, hire a service that does it for you in an automated way. A very used one and I recommend is the Amazon RDS .

facebook itself uses a non-relational model to make this type of data transaction, if that suits you, also check out MongoDB a> and see if it serves your needs well. The learning curve is small, and you can implement it in only part of your system (in your case, interactions between users).

    
09.04.2016 / 19:42