Reputation: 8791
Fields like username, password, and email for example. Also, in StackOverflow's case, submission details like title, content, tags, etc. Does it make that much of a difference? If anyone is confused by my question, by size I mean how large I make the VARCHAR. Are there set standards for these kinds of things?
Upvotes: 1
Views: 248
Reputation: 734
It is very difficult to make any meaningfull assumptions on any kind of data format, especially string lengths and validation rules.
What is a good length for a street address? You might have a very simple address, but other people might have very complex address with a lot of additions (building, room numbers etc). Prematurely optimizing your field lengths may lead to problems for these people and will cause you headaches because changing these limits when your application is live may be very difficult.
To add to this: I suspect that most database will optimize disk usage and communication overhead for you anyway. Look at SQLite, you can supply it with field formats (String, int, etc) but will not actually use them, it will store everything as plain strings. Computing power is so cheap nowadays that these kinds of optimizations are not really usefull (This doesn't hold for all optimizations though)
Really, any kind of field validation is quite difficult: when is an email address valid? Now and then you see some silly regex solutions, but these will always have their limits: they will always reject some complex valid cases, and they will always allow fake addresses. The only true way to valid an email address: send a confirmation mail.
So really: if you are planning an application: try to make as little assumptions on field formats as possible.
Upvotes: 1
Reputation: 8694
Maximum email address length seems to be 256:
http://www.eph.co.uk/resources/email-address-length-faq/
Is that big enough to hold the other things you mention?
-- pete
Upvotes: 0
Reputation: 86336
Size is based on your project requirement but the data type should be considered.
If the field is in the range of char
that should also be declared as char
not varchar
that affect your query speed.
You should consider the data type before declaring columns.
Upvotes: 0
Reputation: 64137
They should be specific to your application.
However if you want the standards for personal information (firstname, lastname etc)., you should check out this link: Standards
Upvotes: 1