| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |
|

08-16-07, 23:39
|
|
Registered User
|
|
Join Date: Aug 2007
Location: Auckland New Zealand
Posts: 113
|
|
|
Data type and standard sizes
|
|
Where can I find a list of the standard accepted sizes for data types (length of strings particularly) like first Name varchar(25) email(35),
|
|

08-17-07, 00:28
|
|
World Class Flame Warrior
|
|
Join Date: Jun 2003
Location: Ohio
Posts: 11,726
|
|
Never heard of such a thing.
Just use char(255) for all strings and float for all numbers. Or better yet, use an XML datatype and you can store anything in it.
....I'm KIDDING guys! I'm just kidding!
__________________
If it's not practically useful, then it's practically useless.
blindman
www.chess.com: "sqlblindman"
|
|

08-17-07, 01:25
|
|
Registered User
|
|
Join Date: Aug 2007
Location: Auckland New Zealand
Posts: 113
|
|
|
|
if I was to use char 255, and I only needed 35 characters I would be wasting 220bytes of space? then times 10,000 records, thats 2.2 MB for One string, That makes sense. Looking for say I want to store an email what would be the maximum size I would want.
|
|

08-17-07, 03:16
|
|
King of Understatement
|
|
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
|
|
blindman was goofing about.
You just use the smallest size that is likely to not cause you problems. There is certainly no official or supported standard. Maybe someone somewhere has published their standards.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
|
|
|

08-17-07, 03:25
|
|
Registered User
|
|
Join Date: Aug 2007
Location: Auckland New Zealand
Posts: 113
|
|
Well in that case,
What would you recommend for max
Email
and Geographic Location (Google maps Style)
I can make estimates on the size but I really want to get it spot on,
|
|

08-17-07, 03:37
|
|
King of Understatement
|
|
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
|
|
Quote:
|
Originally Posted by Nate1
I can make estimates on the size but I really want to get it spot on,
|
I think that's the point - there is no such thing. I can pretty well guarentee that I can create an email address that is longer than any "reasonable" length you are likely to make that field.
Adding extra length to a varchar is cheap. Consider perhaps 40-45 characters for email. This is long but I think better to have a varchar(45) which contains at longest a 34 character string than have to change the schema later when someone is unable to enter their email address.
I have no idea about the second one.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
|
|
|

08-17-07, 03:46
|
|
www.gvee.co.uk
|
|
Join Date: Jan 2007
Location: UK
Posts: 10,156
|
|
We recently encountered truncation issues with
Firstname varchar(20)
Surname varchar(20)
When some clever chap decides to go get a really long surname and join the company 
|
|

08-17-07, 04:47
|
|
vaguely human
|
|
Join Date: Jun 2007
Location: London
Posts: 2,519
|
|
Email addressesI found this which suggests 64 char for name and a max off 255 for the domain. They also mentioned that the name part may expand to 128 characters. So the maximum size might be 128 + 1 + 255 = 384 chars. Also this was written in 1998 so things may of expanded more so now. However I can't imagine anyone having such an address.
So your choice is do you- look at the actual maximum size allowed for an email and cover that ie varchar(384).
- decide a rational size for emails ie varchar(64) and then get someone arrive with a longer email address that invalidates your system.
- accept that you're guessing and simply go for varchar(255) and then use your valuable thinking time on a more interesting part of your design.
Place namesPlace names can can get pretty long around the world:- Llanfairpwllgwyngyllgogerychwyrndrobwyll-llantysiliogogogoch (in wales)
- Tetaumatawhakatangihangakoauaotamateaurehaeaturipu kapihimaungahoronuku pokaiwhenuaakitanarahu (in New Zealand)
- Krung-thep-maha-nakorn-boworn-ratana-kosin-mahintar- ayudhya-amaha-dilok-pop-nopa-ratana-rajthani-burirom-udom-rajniwes-mahasat-arn-amorn-pimarn- avatar-satit- sakattiya-visanukam (in Thailand)
and I guess if tourists continue to flock to the place with the longest names then these names will only ever get longer. Whether anyone actuually comes from these places is another question. Thank god for post (zip) codes. Perhaps ...
Quote:
|
Just use char(255) for all strings
|
blindman may of hit the nail on the head even in jest 
Quote:
Originally Posted by Nate1
if I was to use char 255, and I only needed 35 characters I would be wasting 220bytes of space?
|
Varchars only use the space required for the string (+1 char) so you won't be wasting anything.
Having some strict limitions in your database will at least screen out users with double barreled names, strange yocals and wierd geeks which can't be a bad thing 
Mike
|
|

08-17-07, 05:19
|
|
www.gvee.co.uk
|
|
Join Date: Jan 2007
Location: UK
Posts: 10,156
|
|
Quote:
|
Originally Posted by mike_bike_kite
Llanfairpwllgwyngyllgogerychwyrndrobwyll-llantysiliogogogoch
|
If you've ever seen a street sign for the place (other than the one at the train station there... they're might proud...
Then it's written as "Llanfairpwllgwyngyll" which is a unique place name.
Incidently, Llanfairpwllgwyngyll has the longest single-barreled place name in the world
I think ultimately, just be sensible, don't just make everythign Varchar(8000(!!
|
|

08-17-07, 07:19
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
another scenario that mysql takes care of for ya
if Surname is VARCHAR(20) and you insert a 50-character name, it lets you!

|
|

08-17-07, 07:31
|
|
King of Understatement
|
|
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
|
|
Do you consider that a desirable feature?
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
|
|
|

08-17-07, 07:57
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
try it and see what happens, then you may take a stab at guessing whether i think its actions are desirable
|
|

08-17-07, 08:25
|
|
vaguely human
|
|
Join Date: Jun 2007
Location: London
Posts: 2,519
|
|
Come on guys - here you have the chance of setting up a world standard for user fields and you're all avoiding the original question - what size should the fields be? I've put in some starting values to get you going
Code:
create table Users (
id int,
full_name varchar(60),
first_name varchar(20),
last_name varchar(30),
email varchar(60),
telephone varchar(20),
address_line_x varchar(100),
post_code varchar(40)
)
I had full_name here as well so we could at least set a standard for all likely fields.
Mike
EDIT: added post code (same as zip) and changed numbers for first and last name
Rudy : postal code should be 40 to encompass portugal's
|
Last edited by mike_bike_kite; 08-17-07 at 10:38.
|

08-17-07, 08:26
|
|
King of Understatement
|
|
Join Date: Feb 2004
Location: One Flump in One Place
Posts: 14,905
|
|
sadly I have got no further than installing the engine & tools yet. I will give it a go when I get chance.
__________________
Testimonial:
Quote:
pootle flump
ur codings are working excelent.
|
|
|

08-17-07, 08:41
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
|
|
Quote:
|
Originally Posted by pootle flump
sadly I have got no further than installing the engine & tools yet. I will give it a go when I get chance.
|
sigh
i shall let you know now, then, and you can confirm at your leisure
mysql does not give an error like other databases do ("string or binary data would be truncated") -- instead, it just goes ahead and truncates
good arguments for both approaches
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|