I'm looking for the most efficient way to store a set of values in MySQL. Here is what I am trying to do....
I have a list of hundreds of items (a list that will continue to grow). Each item can be associated with as few as one "resource" or as many as 60. The number of resources can increase, also. When editing an item via a web page, the resources are displayed in the form of checkboxes.
Example:
Item#1
res[1] = 1;
res[2] = 1;
res[3] = 0;
...
res[50] = 0;
res[51] = 1;
Originally I was going to use bit comparison to store integer values, but that would only work so long as the number of resources was 31 or fewer. Even if 64-bit were an option, that would still restrict to 63 or fewer resources.
I could use serialization to store an array of the selected checkboxes.
Or I could simply utilize the DBMS to store a table of the relationships, but this would grow very quickly; i.e.,
ItemID ResourceID
1 1
1 2
1 51
1,000 items would have a potential of 60,000 rows. If I'm trying to find just 60 rows per 1 item, is that going to be efficient? Or if someone tries to find all items associated with 1 resource?
Are there any other methods that are able to accomplish what I am trying to do? Which one would be least taxing on the system? I suppose storing the array as a serialized piece of data in a single column would not work well for search purposes. So perhaps that answers my question already about which would be the most efficient of the two methods above.
Thanks in advance for any advice!