K
K
Karpkarp2016-07-04 20:57:05
Instagram
Karpkarp, 2016-07-04 20:57:05

How to make subscriptions and subscribers?

Hello.
In general, I decided to build a service for photographers, like anyone can go to the service and create their own page, like a photo of a social network. The site is made, there is still not enough knowledge for further) I want to ask how to implement a system of subscriptions and subscribers as in instagram?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya Trifonov, 2016-08-10
@ilyatrifonov

The only thing that comes to mind so far is the user mapping table. The table has the following columns: UserID (user), UserFollowID (user subscribed by UserID). Fill in the table like this:

UserID -> UserFollowID
1 -> 45
1 -> 67
1 -> 2
etc.
Next, make a button that will send a request to the server to call a method that creates such a row in the table: gets the current user; ID of the user being subscribed to; writes a string to the database.
Then you can somehow shovel it with SQL queries and get the desired set of users. For example, those users who are followed by a certain user
SELECT UserFollowID FROM FollowMapping WHERE UserID = 1
Or to reveal some connections among subscriptions. For example, get subscribers of a certain user
SELECT UserID FROM FollowMapping WHERE UserFollowID = 1
Use different query options to get data according to your needs.
In this example, I'm starting from a typical relational database model. This has its downsides, that the table will get gigantic over time, with millions of positions... However, depending on your computing power, you can quickly select user subscriptions from such a large amount of data, or slowly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question