Posts: 292
Threads: 87
Joined: Feb 2011
Reputation:
0
Hello, everybody well i am working on my server right now and i am wondering what would be the smartest thing for me to do the statistics. As of know i am putting all player statistics, such as cash, bank money, fighting style etc. in Users table. In all i have 34 fields right now for the Users table. I am wondering now, is it worth just creating a different table for stats something similar to what a gun saving system looks like? So the stats table would include User ID, User nickname, stat ID and the statistic itself in there and that would be for every player. Or is it just better for me to keep on piling up on the User table, with amount of fields reaching almost 100 or more? And yes i have read, threads on database normalization, but just want some opinions on what is the best thing dealing with statistics. Thank you.
Posts: 1,147
Threads: 109
Joined: Jul 2013
Reputation:
0
Mehh, my personal opinion is having the statistics in the same table, however some things such as a player being banned should be in a different table.
I'd say, if you're scripting a kind of big system then sure, create a new table for it but other than that, use the same table for the statistics.
Posts: 319
Threads: 7
Joined: Jul 2012
Reputation:
0
If you're planning to create another table, only put the UserID in there, along with Stat ID and the value.
The user's name should already be in your Users table.
There is no need to copy it to every other table where a UserID is located, a player's name should only exist 1 time in your entire database.
If there are many statistics, you might find it useful to use another table for it.
If it's less than 15 or so, just include them in the Users table.
Posts: 279
Threads: 10
Joined: Apr 2015
Reputation:
0
Place all player stats on a single table like everything that is written in your enums.
Even better every new enum that needs saving in MySQL(since some doesn't isn't essentially needed saving on the database) needs different tables. So that when you're trying to look something related to a certain enum you will find it.
Now the banning like he is saying, there are two ways of banning an I.P ban and a character ban. If you ban a character just use the single database but if you have an I.P ban thing make a single table that'll save all the I.P's that got ban.
With that said I think you understand what I mean
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
Only store things in the User table that apply to every single user without exception. Storing a bunch of zeros or nulls is pointless. I will usually limit the amount of fields in a single table to a maximum of about 30 before it becomes unmanageable. Also make sure that you don't store things that can be derived or calculated, e.g. if you store birth date then don't store age.
I don't know what your setup is like so I can't give any concrete advice at the moment.
Everything that is related to user keep in the same table. Kills deaths etc.. all stats.