tags:

views:

72

answers:

5

Ok, I am creating a game, I have one table where I save a lot of information about a member, so I have many field in it. How many fields is normal to have in one table? Does it matter? Maybe I should split that info into two-three-four tables? What do you think?

A: 

Hi Hey

"information about a member" - umm always difficult, but I always separate identifiable information into another table and use a salt key to link the 2 together. That way it is not as easy to "hijack" usernames and passwords etc. And you can always use the SALT as a session variable rather than username/password/userId or whatever.

Typically I only store a ID, salt and joining date in 1 table. As I said, the rest I try to "hide" so that they cannot be "linked/hijacked".

Hope helps

+5  A: 

Splitting of data into tables should generally not be dictated by the number of columns, but by the nature of the data. The process of splitting a large table into smaller ones is called normalization.

The only other reason I can think of to split a table is, if you may need data in clusters, i.e. you often need columns A-D together or columns E-L, but never all columns or columns D-F, then you can split the table into two tables, one containing columns A-D and the primary key, the other one containing columns E-L and the primary key.

inflagranti
+1  A: 

Speaking about limits, MySQL says it's 4096 (source).

Yet I haven't seen so big tables yet, even those huge data mining tables don't come close.

You shouldn't be concerned about it as long as your database is normalized. As soon as you can spot same data being stored twice (for example, player table might have player_type column storing some fixed values), it's worth moving such data to separate table, instead od duplicating information in other tables and hence reducing columns count (but that's only "side effect" of normalization, not something that drives it).

jimmy_keen
+4  A: 

Normalize the Database

If you feel you have too many columns, you probably have repeating groups, which suggests you should normalize the database. See an example here: Description of the database normalization basics

Hard MySQL Limits

MySQL 5.5 Column Count Limit

Every table has a maximum row size of 65,535 bytes.

There is a hard limit of 4096 columns per table

Bakkal
45 fields, is it normal? What do you think? And I do SELECT * FROM every page load.
hey
Hard to tell without seeing the table. Try to post the table so the community can give suggestions.
Bakkal
+1  A: 

I've never personally encountered one with more than 500 columns in it, but short of the maximum sizes there's no reason to have any fewer than the design demands. Beware of doing SELECT * FROM it though.

Brian Hooper
I have about 45 fields in it and I do SELECT * FROM every page load.
hey
using `SELECT *` disables some query optimizations; better to select just the columns you use.
Piskvor
Hey, if you need 'em, read 'em. All I suggest is you don't request a lot of data you hardly ever use. You may find it convenient to create a view.
Brian Hooper