I’m new to game db design and struggling how to make a inventory system.
I found two options to design inventory db.
- user-inventory-item 1:N-M:1 system
For user it’s like this
User
----------
id
level
experience
Inventory
----------
user_id
item_id
quantity
Item
----------
id
item_name
item_type
inventory has user_id and item_id and the relation is like 1:N and M:1.
But It’s quite strange to have a user a lot of inventories.
It will make a lot of inventories when each item goes in the inventory db.
- user-inventory-item-item_dictionary 1:1-1:M-1:1 system
User
----------
id
level
experience
Inventory
----------
user_id
Item
----------
id
inventory_id
item_dict_id
quantity
Item Dict
----------
id
item_name
item_type
So I thought user and inventories relations are has_one and inventories and items are has_many.
And itemDictionary has to be one to one with item.
So my question is what design is more better?
Or is there a another design that is usually used?
I’m quite confused with designing inventory db.
Thanks for reading my question.