mmounirf mmounirf -4 years ago 60
MySQL Question

What is the correct datatype if I want to store array of IDs?

I'm developing a mobile application where I want to store in user's table a column to hold array of IDs for groups user's already joined. These IDs should be related to the group entry in groups table. I don't know if there's such a thing as a relational array of IDs, all I found is to make a comma separated values varchar column. What is the best practice to achieve that? I'm using MYSQL and PHP for my API

Answer Source

This is a standard many-to-many relationship:

enter image description here

(I generated the diagram here )

If you Google how to create a many-to-many relationship in MySQL, you'll find plenty of tutorials and explanations. Here is a decent looking one.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download