in reply to Re: MySQL / Perl theory & design conundrum
in thread [untitled node, ID 280779]
If the number of records gets big, you may need a second index on the linking table. Having the index (userID, groupID) as a primary key will indeed keep out duplicate records, and allow mysql to quickly answer the question of what all groups is user X in, because querying with a known userID, mysql can use the left column of the combined index.
But, if you want to know all the users in a given group, the linking table does NOT have an index to look up groups with. (userID, groupdID) does not contain a leftmost prefix (groupID). A table scan will be performed here. So an index on the groupID may be useful.
If your record count stays small, i'd go with dragonchilds index only. But if the numbers get big, the second index will become useful.