How do i implement a follow and unfollow system with php and Mysqli just like Twitter and Facebook?

1k Views Asked by At

I'm really new to programming, and i am trying to implement a follow and unfollow systme just like Twitter and Instagram, but have no clue of how to go about the Database structure.

1

There are 1 best solutions below

0
On

Have a look at database relations (For example some introduction to this topic: https://code.tutsplus.com/articles/sql-for-beginners-part-3-database-relationships--net-8561)

For example a Many-To-Many relation would help here (One user can follow many things, but one thing can be followed by many users)

One way to do that to have third table with only two columns (user, thing) in which the primary keys of each get stored if they have the relationship "follow".