Tutorial :Facebook update like feature


I want to implement a Facebook updates(user action and notifications) on my web application as well. I am using LAMP. Should I make a db table where I store duplicate data or should I make calls to different tables to show user his updates.

Is there a better way to do this.

For Example: When someone comments on user's profile then that should also come in his updates. when some one comments on users's profile this is stored in comments table. There are many functions like this which need to be captured in updates.


I'd say two tables

Action = {id, type_id, details, user_id}    ActionTypes={id, name}  

But it's really hard to to be specific since you don't provide a lot of information on what you want to do exactly


By far the easiest way to do it would be to denormalize it. Put all of your messages/notifications/whatever into one table and query that. Think of it as being similar to an "inbox" for your users.


I'd say it depends on wether you anticipate growth in actions that will be reported in your feeds, and wether you want to be able to build on these actions and search/sort/link/interact with them.

If don't care about extending them, I'd say use the denormalized approach that Matt Grande suggested.

If you want to be able to easily filter, sort and extend, than normalize anything you'd have interest in changing later. An action 'Publisher' could have a name, icon, and the 'Actions' could just be a string with links. The real question is what do you want the feature to do, and how will you and your users interact with it?


I am in the process of doing this on my social network, currently my site has user bulletins but I am changing over to the web 2.0 actions type, so I am basicly going to have the same thing you mention but mine is much more complex because mine will only show actions of users that you are a friend of. I am always open to suggestions on improving this performance as it requires JOINS and such to only show recent activity of friends instead of all users

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »