How can we have facebook style updates on the home page? By updates, i mean it tracks very intelligently when the user updates his first name or last name. Similarly when the user uploads new gallery or photos it shows on the home page along with the photo. How can we track such a thing? How should i store this thing in database? Should i maintain a single generic column and store everything in it? This doesn't look to be a feasible solution. And if it is what information should i actually store in it? Suppose, the user uploads 3 photos to his albums, how should i s开发者_运维问答tore this thing in this column? Should i store the uploaded photos IDs from the Photos table?
Thanks in advance :)
You could use triggers / stored procedures (which I'm not too familiar with). Or you could do it in the application code (which I'll discuss).
I once did an update tracking system so that when the application code saw the update being made, it would 1) run the UPDATE for the user's data and 2) run an INSERT into a generic "timeline" database table. This table would need to have a user_id column, TIMESTAMP column, and a TEXT column. In the TEXT column you could do something like "SO and So updated their profile picture" with an HTML link to their data.
DB purists wouldn't like this (what if the user changes their URL? Then the link is now dead. What if the friend speaks a different language than english?) as it doesn't store relational data, but its fast and easy to program and uses minimal columns.
Otherwise, you could build a table with many columns, each column representing an action that could be performed, and another column representing the ID of the action performed (e.g. the id of the picture that was uploaded), but this is a messy table with a lot of NULL data.
精彩评论