7

A coworker wants to save telphone numbers as Strings in a database I don't get why he doesn't want to use Ints. I think it is stupid because it uses more space and you need to change the type if you want to use it to call someone. He says it is better this way because you can put there "+" and "-" for better readability.

Comments
  • 12
    How do you store leading zeroes in an int?
  • 15
    Or international numbers, like +33678907565?
    Phone numbers are definitely strings, not int
  • 1
    I haven't thought about leading zeros. But the + can be replaced with 00
  • 8
    though storing them as numbers leads to some interesting possibilities:

    select avg(phone) from person;

    ;-)
  • 21
    Your coworker is right. Phone numbers should be stored as a string.
  • 6
    Your co-worker is right, a phone number is not actually a 'number' in any useful sense of the term. It should be stored as a string.
  • 5
    I'm with the coworker here, phone numbers are definitely strings. Sorry
  • 8
    Or to put it another way - you're never going to do any Integer operations on it (arithmetic etc).

    But you probably will do String operations on it (matching against a regular expression, for example).
  • 0
    As people here said, your coworker is right, the only operations you're going to do on the phone numbers are the ones that can be done a string and not on an int, additionally to this you can have more format options by having them stored as a string.
  • 0
  • 4
    "I havent thought about leading zeros but + can be replaced by 00"
    Try thinking about that again it might occur to you that this sentence holds an answer to its second part in its first part ;)
  • 0
    That rant is already comedy gold! xD
Add Comment