1

What would be a good approach to display on a dashboard, status updates from users that are being followed (e.g. twitter) on a MVC framework such as codeigniter.

I have a Table, just for the status update, where I record the ID,user_id & message.

Should I create a DB table where I record who is following who, by recording the Users ID when a user choose to follow someone?

If so how would I make a query to the database to request for status update only for followed users?

4

1 回答 1

0

This is a typical Many-To-Many relationship, so you'll need a table to store this relation. The table would simply contain two user id's one for the follower and one for the one being followed. For example:

Followed_Id (BIGINT) | Follower_Id (BIGINT)

These columns would then both have a foreign key, referencing the ID column of your user table.

There are a few ORM tools for CI, like swatkins notes in his comment.

For the querying of the status updates, you basically have two options:

  • Polling, where your client would periodically poll the backend for new updates
  • Pushing, where your backend will notify your client of new updates

The second option is considered a better approach for problems like these because:

  • It can be implemented asynchronously
  • It avoids unnecessary calls to the backend in case there's no new data
于 2011-10-04T09:28:10.327 回答