I am developing a mass emailing app, that could theoretically send many campaigns a week, and each one sending to thousands of contacts.
I have devised two possible ways to store these campaigns:
- Have a
app_campaigns
table and aapp_campaign_emails
table, creating one row for each email sent while referencing the parent campaign and the actual contact. Theapp_contacts
table would store the actual email address and other data. - Or, to store all the contact IDs in the
app_campaigns
table, in a comma-separated field. That way, there is no need to create multiple records for each campaign.
What would be the best approach? Here, performance and keeping the database small is a priority since a few campaigns can quickly increase the size of the database (there are multiple clients sending multiple campaigns a week, each one with a potentially large list of contacts).
But it would also need to keep track of opens and clicks, which I'm thinking of doing by only recording entries as they happen.
Some apps such as Sendy go for the second approach, and avoid having to create thousands of rows in one go. However, it might get a little messy since doing searches and queries with a comma-separated Id field is harder than just querying the database.
To further complicate things, there should be a way to display each email sent to a contact in a CRM-esque interface. So by using the second approach, it would mean doing FULLTEXT searches in the app_campaigns
table to build a proper list.
Any thoughts?