List of standard lengths for database fields

后端 未结 13 1755
日久生厌
日久生厌 2020-12-02 03:30

I\'m designing a database table and once again asking myself the same stupid question: How long should the firstname field be?

Does anyone have a li

相关标签:
13条回答
  • 2020-12-02 04:03

    Some probably correct column lengths

                                Min Max
    
    Hostname                    1   255
    Domain Name                 4   253
    Email Address               7   254
    Email Address [1]           3   254
    Telephone Number            10  15      
    Telephone Number [2]        3   26  
    HTTP(S) URL w domain name   11  2083        
    URL [3]                     6   2083    
    Postal Code [4]             2   11
    IP Address (incl ipv6)      7   45
    Longitude                   numeric 9,6
    Latitude                    numeric 8,6
    Money[5]                    numeric 19,4
    
    [1] Allow local domains or TLD-only domains
    [2] Allow short numbers like 911 and extensions like 16045551212x12345
    [3] Allow local domains, tv:// scheme
    [4] http://en.wikipedia.org/wiki/List_of_postal_codes. Use max 12 if storing dash or space
    [5] http://stackoverflow.com/questions/224462/storing-money-in-a-decimal-column-what-precision-and-scale
    

    A long rant on personal names

    A personal name is either a Polynym (a name with multiple sortable components), a Mononym (a name with only one component), or a Pictonym (a name represented by a picture - this exists due to people like Prince).

    A person can have multiple names, playing roles, such as LEGAL, MARITAL, MAIDEN, PREFERRED, SOBRIQUET, PSEUDONYM, etc. You might have business rules, such as "a person can only have one legal name at a time, but multiple pseudonyms at a time".

    Some examples:

    names: [
      {
        type:"POLYNYM",
        role:"LEGAL",
        given:"George",
        middle:"Herman",
        moniker:"Babe",
        surname:"Ruth",
        generation:"JUNIOR"
      },
      {
        type:"MONONYM",
        role:"SOBRIQUET",
        mononym:"The Bambino" /* mononyms can be more than one word, but only one component */
      },
      {
        type:"MONONYM",
        role:"SOBRIQUET",
        mononym:"The Sultan of Swat"
      }
    ]
    

    or

    names: [
      {
        type:"POLYNYM",
        role:"PREFERRED",
        given:"Malcolm",
        surname:"X"
      },
      {
        type:"POLYNYM",
        role:"BIRTH",
        given:"Malcolm",
        surname:"Little"
      },
      {
        type:"POLYNYM",
        role:"LEGAL",
        given:"Malik",
        surname:"El-Shabazz"
      }
    ]
    

    or

    names:[
      {
        type:"POLYNYM",
        role:"LEGAL",
        given:"Prince",
        middle:"Rogers",
        surname:"Nelson"
      },
      {
        type:"MONONYM",
        role:"SOBRIQUET",
        mononym:"Prince"
      },
      {
        type:"PICTONYM",
        role:"LEGAL",
        url:"http://upload.wikimedia.org/wikipedia/en/thumb/a/af/Prince_logo.svg/130px-Prince_logo.svg.png"
      }
    ]
    

    or

    names:[
      {
        type:"POLYNYM",
        role:"LEGAL",
        given:"Juan Pablo",
        surname:"Fernández de Calderón",
        secondarySurname:"García-Iglesias" /* hispanic people often have two surnames. it can be impolite to use the wrong one. Portuguese and Spaniards differ as to which surname is important */
      }
    ]
    

    Given names, middle names, surnames can be multiple words such as "Billy Bob" Thornton, or Ralph "Vaughn Williams".

    0 讨论(0)
提交回复
热议问题