I work on a browser game developed with symfony for school project.
In my schema I have a table player and a table inventory (which contains different items) with relation one-to-one.
I’m not sure how I can build the table inventory. After reflexion, I have find two ways to do this :
1.
TABLE inventory
id
id_player
item1
item2
item3
...
But if I want add an item in the game, I have to add a column to my table and if there are a lot of items, I will have many columns.
2.
TABLE inventory
id
id_player
item
quantity
I think this way is better, but the number of records will quickly increase because I have one line by player by item.
There are other methods which are more efficient ? If not, which is the better in the both ?
The second approach should be fine, as long as there’s an index on id_player. I wouldn’t worry about its space usage. If each row takes 25 bytes and each player has 400 types of items and you have 1 million users, that’s still just 10 gigs.