John Smith
John Smith

Reputation: 275

How to create a 'feed' for users (DB Design)?

So on my website users can perform different tasks such as commenting, joining groups, sending messages, giving feedback, etc. Now I want to create a feed on the users profile page which tells everyone what they have been doing, kind of like facebook but much simpler.

Example:

John Doe sent a message to Bob Smith

Bob Smith gave some feedback to John Doe

Bob Smith joined John Doe's group

To do something like this, should I pull all of the information from the appropriate tables or do I insert a row into a 'feed' table every time a task is performed which I want to be included in the feed.

Basically I want to achieve like what they do on stackoverflow with the activity tab on the profile page.

Upvotes: 1

Views: 196

Answers (2)

Joren Van Severen
Joren Van Severen

Reputation: 2349

I think it will be easier if you indeed create an extra table with the user's activity. Checking all those tables, from which you probably don't even need all data, and then format those to a feed is going to take a toll on your server. Also think on the future (eg. what if you were to have 100's of these tables).

Using an extra table allows you to just query the feed-table and use this info. Without having to extract this from the correct tables, as the data in the tables aren't probably useful directly and needs some calculations.

Another point you may consider is future changes to the feed. Say you want to display some more info on the feed, but the appropriate tables don't have that info, you would have to change all these tables (not to mention the scripts/pages that use them to also add the info). But with one feed-table you can add one more element and change the feed-creation method.

Upvotes: 1

Yehonatan
Yehonatan

Reputation: 3225

userid_did(int)|userid_to(int)|operation(int)|date(varchar)|id(int)

I guess?

Upvotes: 0

Related Questions