Search code examples
mysqldatabase-designtwitter

What is the logic of Following and Followers Systems?


I'm woking on some project and I thinking about the follower and following system like twitter.I have members table on database.How can I do follower system.Whats is the logic?I worked about something like that: I created new table that name is following and i have 3 rows.These rows are id,user_id,follower_id. is that enough for me? I have not idea about how can do this system? Can you help me?


Solution

  • Yes, that design is sufficient for a simple following system such as that of Twitter. Of course, some extra data (such as the timestamp, as suggested by @Ina) could be useful and you don't strictly need the id in it.

    I'd recommend something like:

    userID INT PRIMARY,
    followID INT PRIMARY,
    creationTime DATETIME