So to my knowledge there is no sets, lists, dicts, or arrays in mysql. I want to build a system that has two core components, information about a game match, and then a list of the characters played in the match. If there were lists in mysql then I would do something like this:
game_id INT,
characters list<varchar>,
....more data
The basic query that I want to be able to do is something like this:
SELECT * FROM games WHERE characters IN LIST(list);
Its possible I may select with only one character, or i may specify 10 characters. The question is how to do this efficiently in mysql versus using 10 WHERE clauses with OR. There is also no specific ordering to the characters…but I suppose I could order them based on their IDs.
The only way I have thought of doing this nicely is creating the first table with the basic information and a second table with just character ids and the game_id.
Anyone have a suggestion on how to organize this data nicely with some fancy mysql tricks that I may not know about? The queries need to be fast too, as there will probably be a lot of them eventually. It will be way more reads than writes unless I add a view/download counter….than i guess it will be more writes/updates than reads.
Thanks and I am happy to give anymore information.
Two ways I can think of, if I understand your question correctly….
METHOD 1 … adding a
game_characterstable that looks like …… then the query would be something like …
METHOD 2 … using LIKE, less ideal for large databases, but avoids an extra table … the
charactersrecord would contain a bunch of ids from another table,characters, delimited by a period like so “.23.51.252.75.93.”. The query would look likeYour CMS would have to parse and rebuild the string.