MySQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMySQL Help
Receive the tools necessary to be the rock star of your field. Our 12-month program teaches you the evolving world of multi-channel marketing as well as the complex issues and opportunities found in the industry.

ASP Free and Iron Speed Designer are giving away $5,500+ in FREE licenses. Iron Speed's RAD CASE toolset can save up to 80% of your coding time. One free license per week, one perpetual license per month!
Download and Activate to enter!

Web development can be a daunting task, even for specialists. There is a lot of information to absorb and a lot of technologies to learn in order to manage a superior website. When trying to learn the ropes, developers need a reliable source to introduce new ideas that can be easily implemented. When working on large projects, even web veterans may run into a technology or an aspect of a technology that they are unfamiliar with.

Learn More!


Download to Enter
| Contest Rules

Tutorials | Forums

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 February 5th, 2012, 12:18 AM
krocozkid krocozkid is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 4 krocozkid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 sec
Reputation Power: 0
Need help on what data type should i use

hi guys, im currently pursuing my degree and i have DBMS subject and using MySQL. hope i can get help for my studies here.

may i know what is a good data type for storing phone number?? as in, the phone number may be more than one.

example as following, name, phone number, address.

name = Michael
address = Cullom St, no 90 blk 20, Australia
telephone no = 123456789,987654321,678912345, (3 diff numbers)

name = char(8)
address = varchar(50)
phone number = ??

what is the data type for telp no??

any help is greatly appreciated. thanks in advance =)

Reply With Quote
  #2  
Old February 5th, 2012, 01:35 AM
swillis16 swillis16 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 1 swillis16 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 44 m 3 sec
Reputation Power: 0
1. You can store all three numbers as a varchar.
2. You can create three phone number colums in the database with each being a varchar.

Either one is fine, but with option 1 you may have to split the string at the commas if you are making an application using the database.

Reply With Quote
  #3  
Old February 5th, 2012, 01:38 AM
fubes2000's Avatar
fubes2000 fubes2000 is offline
manwich
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2003
Location: Canadanistan
Posts: 575 fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)fubes2000 User rank is Major (30000 - 40000 Reputation Level)  Folding Points: 388781 Folding Title: Super Ultimate Folder - Level 1Folding Points: 388781 Folding Title: Super Ultimate Folder - Level 1Folding Points: 388781 Folding Title: Super Ultimate Folder - Level 1Folding Points: 388781 Folding Title: Super Ultimate Folder - Level 1Folding Points: 388781 Folding Title: Super Ultimate Folder - Level 1Folding Points: 388781 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 10 h 47 m
Reputation Power: 382
As you've written it would be a VARCHAR, though you might want to use more than one field for more than one phone number [home/work/cell/etc] for the sake of efficiency if you need to search based on PN.

If you're storing PNs individually then it's really up to you how best to store them. If you need to be storing things like extensions or symbols like + for international dialing then a string type is best, but if it's only ever going to be digits then a numerical type will be more space/computation efficient.

You could also split the phone numbers off to their own table if there's no real upper limit on the number of PNs you want to associate with a given row/person.

Also, 8 characters is very short for any sort of name field, and I don't know why you'd want it to be CHAR instead of VARCHAR.
__________________

Reply With Quote
  #4  
Old February 5th, 2012, 02:37 AM
krocozkid krocozkid is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 4 krocozkid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 sec
Reputation Power: 0
Quote:
Originally Posted by swillis16
1. You can store all three numbers as a varchar.
2. You can create three phone number colums in the database with each being a varchar.

Either one is fine, but with option 1 you may have to split the string at the commas if you are making an application using the database.

One of the phone number data i have to save consist of 13 numbers with 6 different numbers. Meaning i have to use varchar(84). Is there any other better method? Cheers.

Reply With Quote
  #5  
Old February 5th, 2012, 02:39 AM
krocozkid krocozkid is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 4 krocozkid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 sec
Reputation Power: 0
Quote:
Originally Posted by fubes2000
As you've written it would be a VARCHAR, though you might want to use more than one field for more than one phone number [home/work/cell/etc] for the sake of efficiency if you need to search based on PN.

If you're storing PNs individually then it's really up to you how best to store them. If you need to be storing things like extensions or symbols like + for international dialing then a string type is best, but if it's only ever going to be digits then a numerical type will be more space/computation efficient.

You could also split the phone numbers off to their own table if there's no real upper limit on the number of PNs you want to associate with a given row/person.

Also, 8 characters is very short for any sort of name field, and I don't know why you'd want it to be CHAR instead of VARCHAR.


Thanks for the suggestion. Yep, that was juz an example, my data type for name is varchar(30). Cheers

Reply With Quote
  #6  
Old February 5th, 2012, 10:26 AM
E-Oreo's Avatar
E-Oreo E-Oreo is offline
Moderator
Click here for more information.
 
Join Date: Dec 2004
Posts: 6,459 E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)E-Oreo User rank is General 77th Grade (Above 100000 Reputation Level)  Folding Points: 945 Folding Title: Novice Folder
Time spent in forums: 1 Month 2 Weeks 4 Days 2 h 44 m 4 sec
Reputation Power: 6144
Quote:
One of the phone number data i have to save consist of 13 numbers with 6 different numbers. Meaning i have to use varchar(84). Is there any other better method? Cheers.

Yes, separating them by commas and storing them all in the same field is one of the worst methods possible.

Having multiple fields (phone_number1, phone_number2, etc.) in your table is only marginally better.

The best method is one fubes2000 recommended:
Quote:
You could also split the phone numbers off to their own table if there's no real upper limit on the number of PNs you want to associate with a given row/person.

It gives you more flexibility and is far easier to query.

Phone numbers have a lot of possible variations, it is pretty much always best to store them as varchar.
__________________
How to program a basic, secure login system using PHP

Quote:
Originally Posted by Spad
Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

Reply With Quote
  #7  
Old February 7th, 2012, 07:18 PM
krocozkid krocozkid is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Feb 2012
Posts: 4 krocozkid User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 sec
Reputation Power: 0
Quote:
Originally Posted by E-Oreo
Yes, separating them by commas and storing them all in the same field is one of the worst methods possible.

Having multiple fields (phone_number1, phone_number2, etc.) in your table is only marginally better.

The best method is one fubes2000 recommended:

It gives you more flexibility and is far easier to query.

Phone numbers have a lot of possible variations, it is pretty much always best to store them as varchar.


yeep thanks for the input sir. i adopted the extra tables for the telephone number. cheers =)

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Need help on what data type should i use


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 - 2012, Jelsoft Enterprises Ltd.

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