Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
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:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old March 3rd, 2003, 10:15 PM
GeorgeF GeorgeF is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2003
Posts: 23 GeorgeF User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Choosing the right data type

I am just learning to work with databases so this is a very basic question.

I am working with MySql. I do not need the most efficient possible data storage. I want a database that is easy to use.

I am tempted to use varchar for everything, but the lazy man's solution seems like it might cause problems later.

1) Is using varchar for everything really a bad thing?

2) I have a currency variable (currency symbol + decimal). The type of currency can change. Should I use a Varchar field for the symbol+decimal? Should I strip off the symbol and store it in a varchar and the decimal in a decimal field?

3) Will using varchar for dates and times cause problems latter?

(I tried to answer this by searching on google but the articles were more technical and less philosophical)

Reply With Quote
  #2  
Old March 3rd, 2003, 11:17 PM
Deal-a-Neil Deal-a-Neil is offline
whatUseek
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Northville, Michigan
Posts: 60 Deal-a-Neil User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to Deal-a-Neil
Pick your data types more carefully. varchar is fine for strings, but for dates, use DATETIME. For currency, use DECIMAL with enough significant digits to satisfy all currency types used. If you use varying currencies in your live data set, then create a new column called currency_type and make that a varchar (since you like that column type so), or, be more clever, and try an ENUM (look it up in the MySQL docs if you don't know what it is).

You see, varchar may look like a swell means to store all types of variables; however, when you are doing sorts in queries, that's when you'll pay the piper. There are just a plethora of column types -- explore the space. We need more cowbell.

Reply With Quote
  #3  
Old March 3rd, 2003, 11:29 PM
AlCapone's Avatar
AlCapone AlCapone is offline
Mobbing Gangster
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Sep 2001
Location: "Best City" 2002 and 2003- Melbourne, Australia
Posts: 4,913 AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level)AlCapone User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 h 36 m 31 sec
Reputation Power: 17
Send a message via ICQ to AlCapone Send a message via AIM to AlCapone Send a message via Yahoo to AlCapone
don't use enum too much as this is non-standard and requires a fair bit of hacking when you want to port to other dbs.
__________________
And you know I mean that.

Reply With Quote
  #4  
Old March 3rd, 2003, 11:34 PM
Deal-a-Neil Deal-a-Neil is offline
whatUseek
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2003
Location: Northville, Michigan
Posts: 60 Deal-a-Neil User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to Deal-a-Neil
Okay -- don't use ENUM, use VARCHAR. Heheh. Actually, if you do port to another DBMS, and you have ENUM (sounds like a disease now, eh?) see a doctor immediately. Actually, you can alter the column to be a <sigh> VARCHAR without losing any data.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Choosing the right data type


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway