[Opinion] Loading user assigned items (inventory/equipments)

03/27/2011 12:23 Basser#1
So I'm using a SQL DataBase (MsSQL to be more specific) , and I can't really decide how I should load user assigned items, e.g. the inventory.
I could:
  • load all items at once and assign them to users when they log on
  • load them using a query which would only return items with a specific value as a owner
  • create one table per user, but this would affect organization
  • more ideas?
03/27/2011 12:51 _Emme_#2
I'd say assign everything from outside. I'm loading items/nobility/spells etc separately, and assigning them to the character with the UID.
03/27/2011 13:36 Basser#3
But all in one table?
So load everything at once, and assign them later?
03/27/2011 13:56 _DreadNought_#4
In the source i'm using,

All items in one table and set by UID,
ex:
[ITEMID][for character uid]

then when the character logs in the all the items in the table with the same UID are dished out.
03/27/2011 14:00 -impulse-#5
Quote:
Originally Posted by Basser View Post
But all in one table?
So load everything at once, and assign them later?
Since you are using SQL you can do select * from table where UID = client.UID;
That would take only the rows that are assigned to the UID you want.
03/27/2011 14:42 _Emme_#6
Quote:
Originally Posted by Basser View Post
But all in one table?
So load everything at once, and assign them later?
No, different tables. This will probably cause more loading time, but loading is only done at login (won't be noticeable), but will be more organized.

And as impulse said, at entity loading, just select the rows that have the UID of the entity you're loading, then read all the values.
03/27/2011 17:08 Basser#7
Quote:
Originally Posted by EmmeTheCoder View Post
No, different tables. This will probably cause more loading time, but loading is only done at login (won't be noticeable), but will be more organized.

And as impulse said, at entity loading, just select the rows that have the UID of the entity you're loading, then read all the values.
Than why create different tables lol?
03/27/2011 17:12 _Emme_#8
As I said, more organized. This loading time will only differ a few milliseconds and it's during the login part, not game, so it won't be noticeable.
03/27/2011 17:35 Basser#9
Quote:
Originally Posted by EmmeTheCoder View Post
As I said, more organized. This loading time will only differ a few milliseconds and it's during the login part, not game, so it won't be noticeable.
How is it more organized to have multiple tables for the same thing? 1 table each character would make a big mess too.
03/27/2011 18:36 _Emme_#10
There's a difference between table and column.

What I'm saying is that you'd create a table (note, table) for example, items. So you create an table called items, with columns (note, column) including the entity ID and the item information you want to load.

I'd suggest you do this for most of the stuff, for example skills.
03/27/2011 19:05 CptSky#11
The only things I don't load in memory when I start the server are the characters and the accounts. The difference of memory usage is really not considerable and you don't have to load something more than one time...
03/27/2011 19:44 Basser#12
Quote:
Originally Posted by EmmeTheCoder View Post
There's a difference between table and column.

What I'm saying is that you'd create a table (note, table) for example, items. So you create an table called items, with columns (note, column) including the entity ID and the item information you want to load.

I'd suggest you do this for most of the stuff, for example skills.
Exactly.
A column is only a part of a table.
A table is not a part of a column.
So why create multiple tables for items only?
03/28/2011 00:17 Korvacs#13
Quote:
Originally Posted by Basser View Post
Exactly.
A column is only a part of a table.
A table is not a part of a column.
So why create multiple tables for items only?
He never said create multiple tables just for items he meant, for all the things you need to load (items, skills, quests, etc) You create a table for each of these things (1 table for items, 1 for skills, 1 for quests) and then populate them accordingly.

Clear?
03/28/2011 01:38 .Kinshi#14
In your database have one table for player items, with a column with the owners UID.
When they login, query the table for every item who's owner UID is the same as the UID of the player logging in, and populate a dictionary for that player.
03/28/2011 09:11 _Emme_#15
As explained above, then in the source you query the table (a good sql wrapper is impulse's ).