I'm just thinking up some ideas on an alerts system in a web application and wondering what the best way of going about this it is.

For the sake of an example, I have two tables;

1) tasks
2) comments

Users need to be able to add comments to tasks. When a comment is added, I'd like other users of the application to see that there is a new comment. This will appear at the top of the page, e.g. New Comments To Read.

This link will take users to a summary page of all the tasks that have new comments on them.

To enable this, I'll create a table called alerts (user_id, task_id). Whenever a new record is inserted into the comments table, an additional one will be inserted into the alerts table so to find out if a user has a new comment, all I have to do is query the alerts table.

Once an alert is read, it can be deleted from the alerts table.

Here's the question:

1) Should I scan the alert table every page load to find out if there are new comments?

2) Should I create a boolean field in the users table that would indicate if there are new alerts?

I already have my own ideas but would like some feedback from others who might have some experience about this kind of thing.
.