Reputation:
I am trying to build an email sender in PHP/MySQL where you can choose the group of people (in dropdown menu) and send them a message. I have a {users} table with emails and I am having trouble figuring out how to do groups table.
What columns should I have? or Any other way to do the same thing?
I would be really grateful if you could explain like you would to a beginner :)
Thank you)
Upvotes: 0
Views: 113
Reputation: 19879
You're looking for a many-to-many relationship, which will look something like this (three tables):
group
id
name
user_groups
id
user_id
group_id
users
id
name
email
Whenever a user is added to a group, you will insert a row into the user_groups
table.
Have a read on Database Normalization.
Upvotes: 1