Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 11th, 2012, 10:43 PM
CarlosinFL CarlosinFL is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 51 CarlosinFL User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 8 m 48 sec
Reputation Power: 2
Data Type Sheet Cheat / Guide?

I'm extremely new to SQL and I have no programming language experience whatsoever. I've only been ANSI SQL for about a year so basic SQL is fairly easy as far as SELECT, INSERT, & UPDATE statements but my pro blem is not understanding under what circumstances to use a specific data type. Is there a guide, rule of thumb, or some way I can learn when the appropriate data type should be used?

For example, I just found out today I should never create a datatype of integer for a field storing zip codes.

Reply With Quote
  #2  
Old January 11th, 2012, 11:06 PM
Catacaustic's Avatar
Catacaustic Catacaustic is offline
Code Monkey V. 0.9
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Mar 2005
Location: A Land Down Under
Posts: 1,886 Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level)Catacaustic User rank is General 12nd Grade (Above 100000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 15 h 12 m 20 sec
Reputation Power: 1798
I think that answer to that is... use the most relevant data type. As you've found out, that's not as easy as it sounds sometimes.

The most general guide to that sort of thing is store numbers in numeric fields, dates and times in date/time fields, booleans in boolean fields (if available), and most other things can be stored as text.

Most times it will come down to what you need the data for and how you need to use it. The post (zip) codes are a good example for this. Where I am, post codes are only ever 4 numbers and there's no exception to this, so if I was only wanting local users then I could set up a numerical data type without any problems. However if I needed to look at international users then I couldn't do that because the allowable lengths change and the valid characters change from country to country and sometimes even within countries.

Just know your data. Know what you need to store, know what the possible values can be, and work with that. If you don't know, get an answer from someone that does. If you can't do that, opt for the type with the highest probability of handling everything that you might need.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Data Type Sheet Cheat / Guide?

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap