[MYSQL] What is better?
#1

Hi,

I have table where is 700 fields. I know so much but.. Now i'am trying to hold them in one string and then specific loading. But now i have for ex: unban system i select a field 'BAN' and if it'is 1 player banned or no, but now i need to select all that string which contains maybe 8000-9000 long string, maybe smallest 7000 but still not small. And how about them? is query will be long to give result of that?
Reply
#2

I simply have no words to describe this abomination. The maximum fields you should ever need in a single table is something like 30. Most of my tables won't even go above 10.

If something doesn't apply to ALL users then it shouldn't be in the users table. Not every player is banned, so that shouldn't be in the users table. Not every player has a car so that shouldn't be in the users table. Not every player is in a faction so that shouldn't be in the users table, etc, etc, etc.

Right now, I feel like I'm explaining that 1 + 1 is 2 to a five year old.

The ban table should probably look something like this:

banidtimestampuseridadminidreasonexpires
12014-12-23 19:17:145785978Cheating2015-01-22 19:17:14
  • banid int unsinged primary key auto_increment
  • timestamp datetime
  • userid int unsigned foreign key references users
  • adminid int unsigned foreign key references users
  • reason varchar
  • expires datetime
Reply
#3

Why you think that? if i have a roleplay server and i need to load most everything when player connects? Not every player banned, but still need load and check is banned, car yes but if he have need a load.
Reply
#4

Yes, but that doesn't mean everything should be in the users table! Create a table for bans, create a table for cars! Why is that concept so hard to understand? By putting everything in one table you completely defeat the purpose of a relational database.
Reply
#5

Vince is correct. Use different tables for bans, cars, toys, etc and load from them via a user ID. This is also efficient in the future if you'd like for clean UCP logging. What if you needed to view someone's ban reason manually? Would you scroll through those fields until you found it? That'd be a pain. Just split them into different tables. If not, MySql pretty much becomes usless and you might as well just be using a .ini plugin.
Reply
#6

Can you explain my this, i make same query twice. First time it complete in 1.2 second, and other time in 0.02 ms. How it can be? I'am using VPS, and i off all my server restart VPS.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)