MySQL Help
 
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 ForumsDatabasesMySQL Help

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 September 17th, 2012, 06:23 AM
badger_fruit's Avatar
badger_fruit badger_fruit is offline
Confused badger
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2009
Location: West Yorkshire
Posts: 760 badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 5 h 15 m 18 sec
Reputation Power: 339
Correct data types?

Hello all
I usually foul-up, sorry, post my questions in the PHP forum but today I have a MySQL Database question; probably a very easy one for you DB masters ... What are the correct data-types I should be using to store these values (this is a dump of a PHP array):-


Array
(
[date] => 16/09/2012
[time] => 15:30:46
[anumber] => 1109907096175000
[bnumber] => VOIP
[origin] => 650
[dialled]=> 440906001002
[destination] => 323
[duration] => 313
[cost] => 0.1050
)

Thanks for any help
Regards

A Total Noob lol
__________________
The number for UK Emergencies is changing, the new number is 0118 999 881 999 119 7253

"For if leisure and security were enjoyed by all alike, the great mass of human beings who are normally stupefied by poverty would become literate and would learn to think for themselves; and when once they had done this, they would sooner or later realise that the privileged minority had no function and they would sweep it away"
- George Orwell, 1984

Reply With Quote
  #2  
Old September 17th, 2012, 07:31 AM
deljr deljr is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2012
Location: Wisconsin
Posts: 78 deljr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 11 h 51 m 6 sec
Reputation Power: 1
[date] => 16/09/2012
[time] => 15:30:46

those could be condensed into a single column with a datetime data type

[anumber] => 1109907096175000
[bnumber] => VOIP
[origin] => 650
[dialled]=> 440906001002
[destination] => 323
[duration] => 313
[cost] => 0.1050


as for the rest what are you using now?

Reply With Quote
  #3  
Old September 17th, 2012, 07:55 AM
bobhairgrove bobhairgrove is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2012
Posts: 6 bobhairgrove User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 28 m 40 sec
Reputation Power: 0
Code:
[date] => 16/09/2012
    [time] => 15:30:46

Are these actually just one timestamp? As already mentioned, you could use DATETIME. There is also the TIMESTAMP column type which allows for a default value of NOW() or CURRENT_TIMESTAMP(). If not related, then you can use the DATE and TIME data types instead.
Code:
[anumber] => 1109907096175000
    [bnumber] => VOIP

These both look like they should be stored as text, i.e. VARCHAR(n) where n = the largest possible number of characters. This is especially true if the numbers might contain leading zeros.
Code:
[origin] => 650
Is this a foreign key of some kind to a related table? If so, it should be the same data type as in the referred table, probably some kind of integer.
Code:
[dialled]=> 440906001002
Again, VARCHAR() here;
Code:
[destination] => 323
Same as [origin];
Code:
[duration] => 313
Will there ever be a fractional value? If not, use INTEGER. Otherwise, either DECIMAL (or DOUBLE if rounding errors don't really matter);
Code:
[cost] => 0.1050
Anytime you are dealing with monetary values, use the DECIMAL type.

Reply With Quote
  #4  
Old October 19th, 2012, 07:18 AM
badger_fruit's Avatar
badger_fruit badger_fruit is offline
Confused badger
Dev Shed Novice (500 - 999 posts)
 
Join Date: Mar 2009
Location: West Yorkshire
Posts: 760 badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level)badger_fruit User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 5 h 15 m 18 sec
Reputation Power: 339
Hi
Sorry for not posting back sooner, thanks for the replies, most appreciated!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMySQL Help > Correct data types?

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