views:

179

answers:

1

Greetings All, I've seen similar questions asked before with no conclusive or tested answers.

I'm designing a News Feed system using PHP/MySQL similar to facebooks. Seeing as this table could grow to be quite large -- any inefficiency could result in a significant bottleneck.

Example Notifications: (Items in bold are linked objects)

User_A and USER_B commented on User_C's new album.

User_A added a new Vehicle to [his/her] garage.

Initially, I implemented this using excessive columns for Obj1:Type1 | Obj2:Type2 | etc..

It works but I fear it's not nearly scalable enough, now I'm looking to object serialization.

So, for example my new database is set up like so:

News_ID  |  User_ID  |                 News_Desc            |   Timestamp

  2643         904     {User904} and {User890} commented on     SomeTimestamp
                       {User222}'s new {Album724}.

Anything inside {'s represents data that would be serialized using JSON.

Is this a smart (efficient / scalable) way to move forward?

Will it be difficult to separate the serialized data from the rest of the string using regular expressions?

+1  A: 

What happens if User890 deletes his/her comment? I think you need to be more atomic - possibly storing the type of action (comment) with the actioner (User890), then generate the actual story on the fly, with heavy caching. This would also help the issue of translation, if you extend your site to several markets/audiences.

adam
Very good point. This would mean that I should also store the ID and TypeID of the action element, so for example I could remove the feed entry from my "delete_comment()" function. I never considered translation, and caching would keep my database size minimal.
pws5068
I think denormalization is going to be more efficient here. Does it really matter if the comment is deleted? If it is only a news feed then it is only really static data, I assume.
Louis