Hey, so i'm a bit new to web development and have hit a snag with my site. Just to give a bit of basic background, the site is going to have many users and many groups. Multiple users can be associated with a group and multiple groups can be associated with a user. I'm using php to build the site along with a MySQL database.
I currently have a table with all the users, each having a unique id number, and another table with all the groups each having a unique. So in order to link the two, i wanted to store an array with each group that has all of the id numbers of the users that are linked to that group (same for each user). After searching a bit online I came up with the following ways to go about doing this:
have all the user id values as a long string and have functions that would parse and unparse the ids, potentially use the implode and explode functions
use the serialize function which seemed to me does something similar
Have a table for each group, then each row in that table would be a different user that was linked to that group. Same thing would be done with each user but each new row would be a different group...
So I was initially thinking about doing it using either method 1 or 2, but I feel like the process would be slow and would potentially slow down the site. Also I would not be able to utilize the SQL functions to order stuff.
On the other hand 3 seems like a much more dynamic way to solve the problem. However i feel like I'm going to end up with a billion tables because there are going to be lots of users and lots of groups and that having so many tables would slow down the site. I haven't had much experience so if you could please lead me in the right direction and let me know why that is the best way to go about solving the problem i would really appreciate it.