I have two issues that both resemble each other.
I figured that I can make a table of items. Items have qualities and ID's.
I have come to this solution:
Each character table can have a textbox that holds json data that is key value pairs of item slots [0-49] and item id's, since every item has a unique id.
However I am not sure this is the most elegant solution.
And then this problem, that should be solved the same way? [I think]
I wouldn't encode JSON data in a database -- you want a separate table to link things together.
So, maybe player_item_map
which would have fields item_id
, player_id
(and maybe an internal id if you ever need to refer to the map itself). Then you link arbitrary numbers of items to users (you can use constraints in item ownership is unique, and enforce the item limit somewhere else). Alternatively prepopulate an inventory table with the slots, using the fields player_id
, slot
, item_id
(can be null). Then you don't need to insert or worry about missing rows.
You can do similar for skills, but had a skill_level
field as well.