I'm designing a News Feed system using PHP/MySQL similar to facebook's.
I have asked a similar question before but now I've changed the design and I'm looking for feedback.
Example News:
User_A commented on User_B's new album.
"Hey man nice pictures!"
User_B added a new Photo to [his/her] profile.
[show photo thumbnail]
Initially, I implemented this using excessive columns for Obj1:Type1 | Obj2:Type2 | etc..
Now the design is set up using a couple special keywords, and actor/receiver relationships. My database uses a table of messages joined on a table containing userid,actionid,receiverid,receiverObjectTypeID,
Here's a condensed version of what it will look like once joined:
News_ID | User_ID | Message | Timestamp
2643 A %a commented on %o's new %r. SomeTimestamp
2644 B %a added a new %r to [his/her] profile. SomeTimestamp
%a = the User_ID of the person doing the action
%r = the receiving object
%o = the owner of the receiving object (for example the owner of the album) (NULL if %r is a user)
Questions:
Is this a smart (efficient/scalable) way to move forward?
How can I store a "Preview of the event"? For example, if I want to show the comment that User_A made to User_B (like above, and on facebook's news feed). I have considered using an encoded copy of only the relevant data.. for example JSON encoding the comment text or photo html.. but this seems fragile (the user may delete the photo while it's still in another users' feed)
How can I show messages like: "User_B added 4 new photos to his profile." with thumbnails of the photos?