Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Standard Data Types for Web Addresses, Phone Numbers?

Tags:
  1. Mar 3, 2016 #1

    WWGD

    User Avatar
    Science Advisor
    Gold Member

    Hi All,
    Just curious: what kind of data types does one usually use for web addresses, for phone numbers?
    EDIT: I am using MSSQL 2014 .
    Thanks.
     
    Last edited: Mar 3, 2016
  2. jcsd
  3. Mar 3, 2016 #2

    BvU

    User Avatar
    Science Advisor
    Homework Helper
    Gold Member

    No standards in this jungle. E.g. for phone numbers the forms (or whatever) designers usually take their local favorite and thus exclude the rest of the world. Same with addresses, date/time, etc. etc.

    Side note: I had fun long ago discovering that the default data type for windows forms text boxes turned out to be currency !

    As Georgie says: What else :smile:?
     
  4. Mar 3, 2016 #3

    Borg

    User Avatar
    Science Advisor
    Gold Member

    If you're referring to how to store them in a database, it would probably have to be as some form of a string like varchar.
     
  5. Mar 3, 2016 #4

    Mark44

    Staff: Mentor

    Strings?

    Phone numbers are really strings of digits. US phone numbers are 10 digits (not including the 1 prefix). International phone numbers are 12 digits, including the two-digit country prefix, but not including the + prefix that you sometimes see.

    By "web address" do you mean the URL of a web page, and not an e-mail address?
     
  6. Mar 3, 2016 #5

    WWGD

    User Avatar
    Science Advisor
    Gold Member

    Thanks; is it possible to store the webpage as a link in MSSQL 2014, i.e., so that one can double-click in the DB and access the page?
     
  7. Mar 3, 2016 #6

    WWGD

    User Avatar
    Science Advisor
    Gold Member

    Now that you mention it, I mean both.
     
  8. Mar 3, 2016 #7

    Borg

    User Avatar
    Science Advisor
    Gold Member

    I haven't worked with MSSQL. God only knows what they allow. :wideeyed:
     
  9. Mar 3, 2016 #8

    WWGD

    User Avatar
    Science Advisor
    Gold Member

    Are you insinuating ( the very obvious statement that) Microsoft has a sloppy technical design?
     
  10. Mar 3, 2016 #9

    Mark44

    Staff: Mentor

    For web pages, I'm not aware of any particular format. For an e-mail address there is the user portion (the part before @) and the domain name (after @), which can include a subdomain. This is something I used to work with, but it's been awhile.
     
  11. Mar 4, 2016 #10
    There absolutely are standards, I was an engineer for multiple telecom systems sold all over the world. For web addresses, refer to RFC7230 and use varchar(8000) and for phone numbers refer to RFC3966 and use varchar(22);
     
  12. Mar 4, 2016 #11

    QuantumQuest

    User Avatar
    Gold Member

    I usually work with PHP / MySQL and although I prefer to do as many things as I can inside the database - create stored procedures, triggers etc. wherever I have the chance to do it, most things are usually done through server side scripting. As mentioned above, varchar is the preferred data type for phone numbers, for they may contain symbols as well. For web addresses, you can store them as varchar too and create the links "on the fly" - as we usually say, through scripting.
     
    Last edited: Mar 4, 2016
  13. Mar 4, 2016 #12
    It depends.
    If your web addresses are something like google.com, physicsforums.com etc then it would definitely be varchar(Max value defined in RFC)
    In case they are something like 12.34.56.78 and you need to store a millions to billions of them, then a single separate table with tinyint types may be preferred. A script or some methods need to be used then to construct the requested address.
    For the phone numbers, it is almost the same, you might probably need to head into int types but some numbers like 1800-CALL-ME will surely ask you to make use of a bit of extra memory to store the strings under consideration. :biggrin:
     
  14. Mar 5, 2016 #13
    Such numbers are not unique - how would one handle conflicts and testing.
     
  15. Mar 5, 2016 #14
    Normalize it before putting it in the database and doing and queries on it, make that your primary key. Add another field for the way the user provided the number.
     
  16. Mar 5, 2016 #15

    WWGD

    User Avatar
    Science Advisor
    Gold Member

    Agree, of course there should be a format, a single standard used, same as with dates and all other fields.
     
  17. Mar 5, 2016 #16
    I think you are confusing the database engine with whatever GUI front end tool you are using.
     
  18. Mar 5, 2016 #17

    WWGD

    User Avatar
    Science Advisor
    Gold Member

    Thanks; I thought there was a default choice of GUI; not sure the name, but I thought there was one.
     
  19. Mar 7, 2016 #18

    WWGD

    User Avatar
    Science Advisor
    Gold Member

    Sorry, I quoted your post but somehow replied to a different one. Senility happening earlier than I expected :(.
     
  20. Mar 7, 2016 #19

    WWGD

    User Avatar
    Science Advisor
    Gold Member

    Sorry to bother you all again, how about sthe data type for street addresses, is this also a varchar(n)? Addresses always gave me problems in terms of normalizing; not clear where they begin, where they end, unless maybe if there is a general format, e.g., street number street name, etc.
     
  21. Mar 7, 2016 #20
    I would usually break it up before putting it in, provide different text boxes to ask the user for each part of the address, usually:
    AddressLine1 (1600 Pennsylvania Ave)
    AddressLine2 (Suite 1B)
    City (Washington)
    State/Province (DC)
    Zip/Postal (20500)
    Country (United States)
    AddressType (Home)

    Trying to take it in all at once and parse it is possible, but it'd be difficult, especially if you have to dealt with international addresses.

    I would make each of the a varchar except for AddressType, for which I would create an enumeration.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?
Draft saved Draft deleted



Similar Discussions: Standard Data Types for Web Addresses, Phone Numbers?
  1. C data types problem (Replies: 10)

Loading...