I need some ideas in regards to the database management of the email alerts that my website is sending out.


My website sends out deal alerts of the products on deals everyday. Typically a product deal stays ON for 3-4 days and my script is sending the same deal everyday through emails until it expires. I want to create a log mechanism such that when I send alert emails, it automatically logs what deals have been already sent to the specific user so that next day it wont send the same ones. Currently all my deals are stored in a MySQL database and the alerts are send through a search query. Typically each email would have a list of deals that matches the keyword provided by the user.

Please help out.. Thanks in advance!

Member Avatar


Unless we know how you're storing the data and sending the emails, it's difficult to comment.

You could have a link table:


For a deal, search for users that have specified the keyword but are NOT in the link table matching user_id and deal_id
The user_id/deal_id pair is only inserted on successful email
You can remove pairs when the deal expires (e.g. via cron job) in order to avoid growing your table to a ridiculous size.