What are the best data types to use for a members table and scores table on a mysql database?
I am creating a game in Java which connects to a hosted mysql database. I am unsure of which data types to use for each of the fields.
The fields I have are:
TABLE tMembers
ID INT(11)
firstName VARCHAR(255)
lastName VARCHAR(255)
email VARCHAR(255)
username VARCHAR(255)
password VARCHAR(255)
TABLE tScores
ID INT(11)
SCORE INT(11)
DATE DATETIME
I have heard a few things on SO and just form googling about the efficiency of using VARCHAR(80) for emails etc as emails cannot be longer than this, is this true?
For names, is varchar better than text (as a name cannot contain numbers or symbols, why not just use text?)
Also, for the ID, should I use INT or INTEGER?
Any help is more than appreciated.
yes, if you define a column as varchar(x), the length of the value you want to save into that column should smaller than x.
varchar contains (Max length) less characters than text, depends on the mysql version you are using. e.g. 5.03+ varchar can contain 65535 characters. but for your requirement, a varchar type for “names” would be ok.
as far as my understanding, the INT and INTEGER in mysql are the same. check
http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html
there you can see: