New course! Every coder should learn Generative AI!
Try a free lesson+ 1
Don't know nothing about your table layout or structure; so I don't know if this was even feasible.
Create a table that contains two columns, e.g. 'user_id' and 'follower_id'. Both IDs saved in this table should strictly reference to user ID in users table, meaning you should not allow insertion or modification by arbitrary value here.
Suppose you have a user with ID 1; when someone follows user with ID 1 - you create new record with value 1 for 'user_id' column and the follower's user ID for 'follower_id'.
Example (in table)
user_id folllower_id
1 2
1 3
...
Here means user with ID 1 is followed by 2 users, those are users with ID 2 and 3.
* This table can also be used to record users that are being followed.
- 1
pubg