Welcome Guest, Not a member yet? Register   Sign In
Best way to store user activities

(12-06-2017, 11:36 AM)PaulD Wrote: Your method is correct. You would have a table of user_id, user_following_id, and then select the timeline for user_id in a single query, gathering the latest posts of all the users in your array of user_following_id's including the actual user_id too of course. This should be fine on a normal single server database for a large amount of data.

As for 'billions', yes you will have lots of speed problems. Dealing with big data sets like that is a massive task, one I have never had the pleasure to work on, except once on a very big pensions project long ago, but I was just a junior doing tiny parts of a massive code base.

But working on users to get up to millions is quite a task in itself, and by then you would be in a position to not be working on the project alone in all probability, with hopefully the investment to put into place distributed data servers. For now, I would put the problem of billions away for a while, you may never get anywhere near that problem.


Thank you for your reply!
Yeah, I know that maybe I'll never work on billions data, but I want to learn also some "hard" technologies. 

However, I created a MySQL table "users_actions" with this fields: user_id, post_id (that is NULL when the action is about following user), action (an enum with the type of action [like, dislike, comment, follow, creation post]), action_at (a timestamp), user_two_id (when I follow an user I insert the id of this user).

To not overload the data in the table, I update the action_at for action like dislike or like. Instead: user has put like to a post, and the day after he puts dislike to the same post. I update only the past row (I update action's field and action_at's field), without creating new one. Is it a good thing?

Another question. I want to add also the emoji in my post. I know that there is some replace ("Big Grin" => replace to image.gif"). Actually I filter the messages like that:
PHP Code:
$message filter_var($this->input->post('message'), FILTER_SANITIZE_STRING
so if I write a message like "<script>alert("hello");</script>" I'll have only "alert("hello");". Now: there is some way to add the emoji (instead the emoji in iPhone's keyboard or some android phone)? Maybe editing the charset? (now it is utf-8)..

The last question. I want also to create a server to manage the notification foreach user. In the past I used NodeJS with socket.io, but I don't like it so much. Maybe you can reccomend me something about that also Tongue. I was looking for something in python, some websocket in .py..

However, thank you =)!

Messages In This Thread
Best way to store user activities - by theedo - 12-06-2017, 09:38 AM
RE: Best way to store user activities - by PaulD - 12-06-2017, 11:36 AM
RE: Best way to store user activities - by theedo - 12-06-2017, 01:18 PM
RE: Best way to store user activities - by theedo - 12-07-2017, 04:39 AM

Theme © iAndrew 2016 - Forum software by © MyBB