I recently thought that storing an array in MySQL database would solve my problems… then I went and banged my head on a wall until I realised that there was an easier solution to my problem. Unfortunately I can’t seem to figure out what the hell I need to do.
I have two tables. User and Entry. Each user can be the Author of any number of entries. One to many right? Well the problem comes from the fact that each entry can have many users. -_-;
As you can imagine, doing this using arrays would be…not only cumbersome but also stupid, especially if someone managed to accumulate 2000 entries. I had anticipated that I might need to create an extra table and some resources do seem to suggest it but the resources aren’t as clear as I would have hoped. I will need to get all the users for a post and somewhere else, I’ll need to get all the posts for a user.
Can someone explain the best way of doing this? (Without using arrays of course =p)
you need to make 3 tables:
if you want to get an entrys users, just do
and to get all entrys of a user, just do it the other way around: