1

I have a program where the user can enter multiple email addresses to get notification. I'm creating a field in the database to keep track of this and I'm not sure what would be the best data type to choose for all the email addresses. At this point I believe we will limit it to 4 email addresses.

What data type would be appropriate here for mysql?

Not sure this is relevant but I plan to serialize the data (with php function) When processing the email addresses. Interested in any feedback on my plans and if there is a better way to do this.

Tom
  • 2,604
  • 11
  • 57
  • 96

1 Answers1

4

This indicates that you have 1:many relation of user:email addresses. Create another table with user_id and email columns and link it up to your users table via user_id.

Never serialize data and stick it in a column, you'll regret it later.

Furicane
  • 1,173
  • 6
  • 18
  • yes. Especially given the comment "At this point ". I've seen requirements that say "we only want 'this' and we will never want 'that'" and then when they see a demo... they want 'that'. – Michael Durrant Dec 30 '11 at 02:24
  • I have one main user table (user) and another table (xuser) with user_id and the plan is to add a email column. It is linked up. So what I have is 1 user can have up to 4 email addresses in this new email column. Not sure I understand why I wouldn't serialize the data. Can you please expand? – Tom Dec 30 '11 at 02:26
  • [Is storing a comma separated list in a database column really that bad?](http://stackoverflow.com/questions/3653462/is-storing-a-comma-separated-list-in-a-database-column-really-that-bad) Short answer: **Yes, it is** – ypercubeᵀᴹ Dec 30 '11 at 02:35
  • You could additionally split the email into 2 parts/columns `emailname` and `emailserver` for further normalization. – ypercubeᵀᴹ Dec 30 '11 at 02:57