MySQL - How should I save things?
#4

Quote:
Originally Posted by Stefhan
Посмотреть сообщение
1. When it comes to accounts, it seems unlikely that I should save everything in one table.

How do you guys suggest I split the tables? What should I put where? For example, password, name, id etc go well together, but should I have a seperate table for weapons, preferences and so on? How long should my tables get? And how would I go from making sure all the tables are linked up/loaded together correctly?
Correct. Split them just like you said: player main data, weapons, preferences etc. A good table design should not have more than 10-15 columns. Link the child-table with FOREIGN KEY to main players (parent) table. After a player is successfully logged in, you know their registration ID so you do not even need JOINs.

Quote:
Originally Posted by Stefhan
Посмотреть сообщение
2. When saving data, should I save everything on OnPlayerDisconnect, or seperately when it gets changed? Currently, I have a forward/public that gets called at OnPlayerDisconnect which saves everything. Also, does that cause major issues? Saving a lot of stuff in one go? I imagine it would mess up with a GMX if it becomes too much.
No, not everything at once. Save data when they change and save on disconnect those who do not.

Quote:
Originally Posted by Stefhan
Посмотреть сообщение
3. Interesting statistics.
How do I go over saving interesting data such as how many players have joined my server on a day, how much time someone has played in total/over a week and so on? I've seen people have such tables but have yet to figure out how it's done, and I can't find any clear guides on it.
A table that stores connect and disconnect time for players. Using aggregate functions can allow you to count distinct players in a specific timeline or you can count the total gameplay time of a player.
Reply


Messages In This Thread
MySQL - How should I save things? - by Stefhan - 01.01.2019, 00:20
Re: MySQL - How should I save things? - by PowerMwK - 01.01.2019, 00:26
Re: MySQL - How should I save things? - by Stefhan - 01.01.2019, 00:31
Re: MySQL - How should I save things? - by Calisthenics - 01.01.2019, 09:48
Re: MySQL - How should I save things? - by AjaxM - 01.01.2019, 11:33
Re: MySQL - How should I save things? - by Stefhan - 02.01.2019, 10:06
Re: MySQL - How should I save things? - by BlackyX - 02.01.2019, 10:58

Forum Jump:


Users browsing this thread: 4 Guest(s)