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?
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:
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:
The second option is considered a better approach for problems like these because: