SA-MP Forums Archive
Is it worth the MySQL samp normalization? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Is it worth the MySQL samp normalization? (/showthread.php?tid=658947)



Is it worth the MySQL samp normalization? - BlasterDev - 17.09.2018

Option 1:

Table1
id_user | Name | Health | Armour | Money | Skin
1 | Juan | 100.0 | 100.0 | 100 | 5
2 | Juan2 | 100.0 | 100.0 | 100 | 5

Option 2:

Table 1
id_user | Name
1 | Juan
2 | Juan2

Table 2
id_reference | value_action | Value
1 | Health | 100
1 | Armour | 100
1 | Money | 50
1 | Skin | 5
2 | Health | 100
2 | Armour | 100
2 | Money | 50
2 | Skin | 5

Option 1 or Option 2

Which would be better imagining having millions of users and data.


Re: Is it worth the MySQL samp normalization? - spinu - 17.09.2018

first one cause it is nice to have userid as kind of index.
Nobody uses the second option

Although Im not sure why you are storing Health and Armour ??


Re: Is it worth the MySQL samp normalization? - iLearner - 17.09.2018

It is always a good practice to normalize your db.


Re: Is it worth the MySQL samp normalization? - BlasterDev - 17.09.2018

which one is your favorite?


Re: Is it worth the MySQL samp normalization? - iLearner - 17.09.2018

Probably option 1 in this case.
but if you were saving something like player weapons, option 1 wouldn't be good, you'd have to use another table.


Re: Is it worth the MySQL samp normalization? - BlasterDev - 17.09.2018

To finish the post, things like
wanted level
time Jail
jail
etc.
it is better to normalize it or to add it in columns is to have an idea


Re: Is it worth the MySQL samp normalization? - spinu - 17.09.2018

I would store login data, skills, money, wanted, jail and stuff like that in one table and use another table for inventory.


Re: Is it worth the MySQL samp normalization? - AmirSavand - 17.09.2018

It's ok for all the data you need upon login to be in one table.

But extra data (like inventory, stats, etc.) can be in a separated, and nothing happens if you keep all in one row.

It's the matter of slight speed and best practice.