Inventory system with coordinates in SQL.

I’ve been googling around on something that can start me helping on SQL, I’ve also been reading some of the SQL tutorials, and I’ve done a quick search on w3schools, nothing that really tells me on multidimensional tables.

Is it possible to story an inventory in the database WITH coordinates of the slots and the items in them.

I figured I could either:

  • hardcode all the rows for the slots in, allowing no expansion
  • the whole inventory in one string I explode and implode everytime
  • multidimensional arrays stored in one column?

Store the item along with its position? Use a table like this:


i wouldnt use x and y to determin where to put it , i would use index’s , and i would use it like this:


So I would link the index with the itemID and count.

But wouldn’t this be slower then a normal table, considering I will write a lot to the inventory too?

Edit: I just ran into a problem, I want ALL the players inventory in one table, so an index isn’t going to cut it.

Edit: Would storing an array work?

someone correct me if im wrong but wouldnt glon be of use here since it makes a table into a string?

Why wouldn’t storing the index work? How are you storing the inventory if not already in a table?

Store it as Nevec posted

you can store it all in one table , just make the steamID an index for the mysql.
i am not pro in sql , but you would want to do somthing like this.

the sql table:

steamID | Name | Items

and then do :

items = 3,2,5;5,2,7;ect

INSERT Items = items WHERE SteamID = ply:SteamID()