19.06.2018, 12:37
The database structure you are describing has many flows:
• 50 unused columns
• duplicates
Try to maintain 15-20 columns per table and not more.
Having the same item multiple times when can be combined into one is not good either.
The ideal database structure would be like the current one: <userid>, <itemid>, <amount>
But instead of sending a DELETE query and multiple INSERT, combine them.
A player can have an item only once so <userid>, <itemid> is a UNIQUE constraint. If set like this, when executing a query such:
It will do either of these:
• Insert a new record if it does not exist.
• Update amount of item for X player and Y item.
• 50 unused columns
• duplicates
Try to maintain 15-20 columns per table and not more.
Having the same item multiple times when can be combined into one is not good either.
The ideal database structure would be like the current one: <userid>, <itemid>, <amount>
But instead of sending a DELETE query and multiple INSERT, combine them.
A player can have an item only once so <userid>, <itemid> is a UNIQUE constraint. If set like this, when executing a query such:
pawn Код:
"INSERT INTO Inventory VALUES (%d, %d, %d) ON DUPLICATE KEY UPDATE amount=%d;"
• Insert a new record if it does not exist.
• Update amount of item for X player and Y item.