我正在设计一个数据库表,问自己这个问题:名字字段应该多长?

谁有最常见的字段(如名字、姓氏和电子邮件地址)的合理长度的列表?


当前回答

我想找到同样的答案,在公认的答案中提到的英国政府数据标准听起来很理想。然而,这些似乎都不存在了——经过长时间的搜索,我在一个存档中找到了它:http://webarchive.nationalarchives.gov.uk/+/http://www.cabinetoffice.gov.uk/govtalk/schemasstandards/e-gif/datastandards.aspx。需要下载zip,解压,然后在html文件夹中打开default.htm。

其他回答

我刚刚查询了美国数百万客户的数据库。

名字的最大长度为46。我猜是50个。(当然,其中超过25岁的只有500个,而且都是数据导入导致该领域出现额外垃圾的情况。) 姓与名相似。 电子邮件地址最多62个 字符。大部分是较长的 实际上是电子邮件列表吗 用分号分隔的地址。 街道地址最多95 字符。长点的都是 有效的。 最大城市长度为35。

对于美国人来说,这应该是一个不错的统计分布。如果你需要考虑本土化问题,数值可能会有很大差异。

我通常会选择:

名字:30个字符 姓氏:30个字符 电子邮件:50个字符 地址:200个字符

如果我担心名称字段太长,我有时也会将名称字段设置为50,因为现在存储空间很少成为问题。

一些几乎肯定正确的列长度

                            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

对个人名字的长篇大论

一个人的名字要么是多名(一个名字有多个可排序的组件),要么是单名(一个名字只有一个组件),要么是图画名(一个名字由一张图片表示——这是因为像Prince这样的人)。

一个人可以有多个名字,扮演不同的角色,比如法定的、已婚的、未婚的、首选的、绰号、笔名等。您可能有业务规则,例如“一个人一次只能有一个合法名称,但一次只能有多个笔名”。

一些例子:

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 */
  }
]

名字、中间名、姓氏可以是多个单词,如“比利·鲍勃·桑顿”或“拉尔夫·沃恩·威廉姆斯”。

Just looking though my email archives, there are a number of pretty long "first" names (of course what is meant by first is variable by culture). One example is Krishnamurthy - which is 13 letters long. A good guess might be 20 to 25 letters based on this. Email should be much longer since you might have firstname.lastname@somedomain.com. Also, gmail and some other mail programs allow you to use firstname.lastname+sometag@somedomain.com where "sometag" is anything you want to put there so that you can use it to sort incoming emails. I frequently run into web forms that don't allow me to put in my full email address without considering any tags. So, if you need a fixed email field maybe something like 25.25+15@20.3 in characters for a total of 90 characters (if I did my math right!).

我想找到同样的答案,在公认的答案中提到的英国政府数据标准听起来很理想。然而,这些似乎都不存在了——经过长时间的搜索,我在一个存档中找到了它:http://webarchive.nationalarchives.gov.uk/+/http://www.cabinetoffice.gov.uk/govtalk/schemasstandards/e-gif/datastandards.aspx。需要下载zip,解压,然后在html文件夹中打开default.htm。