Jump to content
Larry Ullman's Book Forums

Realistic Values For Datatypes


Recommended Posts

I wanted to ask, what do you think is a reasonable number of characters to have in MySQL for

 

1. Username

2. Email

3. First Name

4. Last Name

5. Address

 

I am seeing various results in different websites

 

Ebay has more than 100 characters that can be held for all of these variables. Larry's books holds these values:

 

1. Username Varchar(30)

2. Email Varchar(80)

3. First Name Varchar(20)

4. Last Name Varchar(40)

5. Address Varchar(80 + 80 = 160)

 

Do you Larry or anyone have an opinion on this, and i was to start out holding figures like this, would it be easy to add more into SQL later?

Link to comment
Share on other sites

I don't have any hard numbers. It's always best to err on the side of making the sizes too big to begin with. Later on you can always pare down the sizes based upon the actual data you have, if you want.

  • Upvote 1
Link to comment
Share on other sites

Okay thanks for that Larry i just needed to here from an expert like you. I will start of with Varchar(100) or more and possibly more for addresses then do an SQL SELECT statement on one of the columns later to check the max value of letters then i can tailor it off to my needs. I am taking your advise on building a practice version of my site which i can then scrap and redo the whole thing. I am starting to build it in Yii already. But tell me one thing, how do you handle say for instance running your website on localhost with database connection setting being different to how they are on your server? Just set different setting for both?

Link to comment
Share on other sites

Well, you could use the same settings on both, so long as they're secure on your local environment is secure. Or could just use a slightly different configuration file for the live version. I find that once I get to the point of putting the site on a live server, my configuration settings are unlikely to change again.

  • Upvote 1
Link to comment
Share on other sites

 Share

×
×
  • Create New...