Freelancers Network
 
skill list top cap
Homepage
Join the Freelancer's Network
Update your details
Find a freelancer
Post a project
Find a project
Projects Archive
Post a job
Find a job
Jobs Archive
See Dan's Pages
See Andy's Pages
Link to this site
Resources
Join/Leave Forum
Forum Messages
+Additions+ Adverts
Advertising
Contact Us
Subscribe to our newsletter - enter your email address and hit return
Freelancers.net is owned and operated by Andy Stowell and Dan Winchester
skill list end cap
guru web hostcom

Find me again on Freelancers.net

RE: FN-FORUM: Storing the leading 0 of product codes in MySQL

date posted 11th October 2006 12:15

[EMAIL REMOVED] wrote:
> Is there a reason to store it as a number? If you're not
> performing mathematics on it then it's best practice to store
> it as text (at least that's what I was told). So for example
> phone numbers should always be stored as text. Text uses
> less memory than numbers. Also why the 2 fields for product
> codes? I guess you have your reasons but it seems odd.
> Paul

New one on me. I would say the type should reflect the nature of the data.
Although a telephone number contains mostly digits it is really a text
string so that is perhaps a valid case, however anything that is truly
numeric would be best stored in a numeric field I believe, irrespective of
your application happes to currently perform any maths no it.

As far as storage space is concerned, I don't know the internal mechanics of
the various databases, but my guess would be it is close to how the computer
itself would store the value in memory - 1 byte can store 256 values for
numbers or a single digit (at very best, with ascii text) if stored as a
string. So numeric storage in that simplest example would be stored about
2.5 times more efficiently as a number (e.g. 40000 takes 5 bytes as text and
2 bytes as numeric).

As I say reality will be more complex (integer/floating point numbers,
unicode text etc.) but I find it very hard to believe that text storage of
numbers would ever be more efficient than numeric storage?

Regards,

Dai

--
TechnologyAngel
http://www.technologyangel.co.uk/




Messages by Day
October 31st 2006
October 30th 2006
October 29th 2006
October 28th 2006
October 27th 2006
October 26th 2006
October 25th 2006
October 24th 2006
October 23rd 2006
October 22nd 2006
October 21st 2006
October 20th 2006
October 19th 2006
October 18th 2006
October 17th 2006
October 16th 2006
October 15th 2006
October 14th 2006
October 13th 2006
October 12th 2006
October 11th 2006
October 10th 2006
October 9th 2006
October 8th 2006
October 7th 2006
October 6th 2006
October 5th 2006
October 4th 2006
October 3rd 2006
October 2nd 2006
October 1st 2006


Messages by Month
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006


Messages by Year
2008
2007
2006
2005
2004
2003
2002
2001
2000