database 名中间名姓。为什么不是全名?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1122328/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 07:23:43  来源:igfitidea点击:

First name, middle name, last name. Why not Full Name?

databasedatabase-designuser-interface

提问by ashraf

I am trying to find a better approach for storing people's name in the table. What is the benefits of 3 field over 1 field for storing persons name?

我试图找到一种更好的方法来在表中存储人名。3 个字段比 1 个字段用于存储人名有什么好处?

UPDATE

更新

Here is an interesting discussion and resources about storing names and user experience

这是关于存储名称和用户体验的有趣讨论和资源

Merging firstname/last name into one field

将名字/姓氏合并到一个字段中

采纳答案by raoulsson

Keep your data as clean as you can!

尽可能保持数据干净!

How?

如何?

Ask your user only as fewthings as you absolutely needat the time you ask.

问问你的用户只有尽可能少的事情,你绝对需要在你提问时间。

How you store the name does not matter. What does matter is that

您如何存储名称并不重要。重要的是

  1. the user experience is as good as can be
  2. you don't have false data in your system
  1. 用户体验尽可能好
  2. 您的系统中没有虚假数据

If you annoy the users with mandatory fields to fill in and re-question them several times, they can get upset and not buy into your application right there and then. You want to avoid bad user experiences at all times.

如果您用必填字段惹恼用户多次填写并重新提问,他们可能会感到不安,并且不会立即购买您的应用程序。您希望始终避免糟糕的用户体验。

No user cares how easy it is for you to search your database for his middle name. He wants to have a easy, feel good experience, that's it.

没有用户关心您在数据库中搜索他的中间名有多容易。他想要一个轻松的、感觉良好的体验,仅此而已。

What do users do if they are forced to input data like their postal address, or even email address when they only want a "read-only" account with no notifications needed? They put garbage data into your system. This will render your super search and sort algorithms useless anyway.

如果用户只想要一个不需要通知的“只读”帐户,而被迫输入诸如邮政地址或电子邮件地址之类的数据,他们会怎么做?他们将垃圾数据放入您的系统。无论如何,这将使您的超级搜索和排序算法无用。

Thus, my advice would be in any app to gather just as little information from your user as you really needin order to serve them, no more.

因此,我的建议是在任何应用从用户的信息很少只是收集尽可能你真的需要,以服务于他们,仅此而已。

If for example you run a online shop for pet food, don't ask your users at sign-up what kind of pets they own. Make it an option for them to fill in once they are logged in and all happy (new customers). Don't ask them their postal address until they order stuff that is actually carried to their house, stuff they pay for and thus care that YOU have their exact coordinates.

例如,如果您经营一家宠物食品在线商店,请不要在注册时询问您的用户他们拥有哪种宠物。使他们可以选择在他们登录并且都很高兴(新客户)后填写。不要问他们的邮政地址,直到他们订购实际运送到他们家的东西,他们支付的东西,因此关心你有他们的确切坐标

This will lead to a lot better data quality and this is what you should care about, not technical details the user has no benefit from....

这将带来更好的数据质量,这是您应该关心的,而不是用户无法从中受益的技术细节......

In your example I would just ask for the full name (not sure though) and once the user willingly subscribes to your newsletter, let the user decide how he/she wants to be addressed...

在您的示例中,我只会询问全名(虽然不确定),一旦用户愿意订阅您的时事通讯,让用户决定他/她希望如何称呼...

回答by RichieHindle

You can always construct a full name from its components, but you can't always deconstruct a full name into its components.

你总是可以从它的组成部分构造一个全名,但你不能总是将一个全名解构成它的组成部分。

Say you want to write an email starting with "Dear Richie" - you can do that trivially if you have a given_namefield, but figuring out what someone's given name is from their full name isn't trivial.

假设你想写一封以“Dear Richie”开头的电子邮件——如果你有一个given_name字段,你可以很容易地做到这一点,但从他们的全名中找出一个人的名字并不是微不足道的。

You can also trivially search or sort by given_name, or family_name, or whatever.

您还可以通过given_name、 或family_name或其他任何方式进行简单的搜索或排序。

(Note I'm using given_name, family_name, etc. rather than first_name, last_name, because different cultures put their names in different orders.)

(请注意,我使用的given_namefamily_name, 等而不是first_name, last_name,因为不同的文化以不同的顺序放置他们的名字。)

Solving this problem in the general case is hard - here's an article that gives a flavour of how hard it is: Representing People's Names in Dublin Core.

在一般情况下解决这个问题很困难 - 这里有一篇文章说明了它的难度:在都柏林核心中代表人物姓名

回答by Colin Mackay

As others have said, how do you decompose a full name in to its component parts.

正如其他人所说,您如何将全名分解为其组成部分。

  • Colin Angus Mackay
  • Jean Michel Jarre
  • Vincent van Gogh
  • Pablo Diego José Francisco de Paula Juan Nepomuceno María de los Remedios Cipriano de la Santísima Trinidad Ruiz y Picasso
  • 科林·安格斯·麦凯
  • 让·米歇尔·雅尔
  • 文森特 - 梵高
  • Pablo Diego José Francisco de Paula Juan Nepomuceno María de los Remedios Cipriano de la Santísima Trinidad Ruiz y Picasso

How do you reliably decompose that lot?

你如何可靠地分解那么多?

To learn more, see falsehoods programmers believe about names.

要了解更多信息,请参阅程序员相信的关于名称的谎言

回答by John Saunders

I was looking up the Spanish Civil Warthe other day, and found this exception to most rules:

几天我正在查找西班牙内战,发现大多数规则都有这个例外:



Next time I'm working on a system that has to store names, I'm going to try something radical: designing from the requirements.

下次我在开发一个必须存储名称的系统时,我将尝试一些激进的方法:根据需求进行设计。

What are we going to use the names for?

我们要用这些名字做什么?

  1. Name on an address label for the postal service
  2. Greeting on the website
  3. Informal name
  1. 邮政服务地址标签上的名称
  2. 网站上的问候
  3. 非正式名称

Based on what the names will be used for, we'd determine how much information to store. Maybe we allow the user to enter all three of those, including line breaks in the first case (Generalissimo Franco might want his full titles and appointments listed, if he weren't still dead). Maybe we provide First, Middle, Last, Generation as an option, and fill in the rest as defaults. Maybe we offer other common options like Surname, Given Name.

根据名称的用途,我们将确定要存储多少信息。也许我们允许用户输入所有这三个,包括第一种情况下的换行符(如果他还没有死,佛朗哥大元帅可能希望列出他的完整头衔和约会)。也许我们提供 First, Middle, Last, Generation 作为选项,其余填写为默认值。也许我们提供其他常用选项,如姓氏、名字。

This is in contrast to the old-style First, Middle, Last we've used since before I started programming in COBOL back in 1975, and have "made fit" ever since.

这与我在 1975 年开始使用 COBOL 编程之前我们一直使用的旧式 First、Middle、Last 形成对比,并且从那时起就“适应”了。

回答by Peter Recore

Unfortunately this is kind of like asking what is the best way to store a number in the database. It depends on what you are going to do with it - sometimes you want an int,other times a byte, and sometimes a float. With names it depends on things like what cultures do you expect your users to come from, what you plan on doing with the names (will you be using these names to connect with another system that stores names as "last name, first name"?), and how much you can afford to annoy your users. If this is an internal HR application, you can probably afford to annoy the users a lot, and have a very structured, formal breakdown of name components (there are way more than 3 - don't forget mr/mrs, jr, III, multiple middle names, hyphenated last names, and who knows what else if you are trying to handle names from all cultures. If you have a webapp that users might or might not care about, you can't ask them to care too much.

不幸的是,这有点像询问在数据库中存储数字的最佳方式是什么。这取决于你打算用它做什么——有时你想要一个整数,有时一个字节,有时一个浮点数。对于名字,它取决于诸如您希望用户来自什么文化、您打算用名字做什么(您是否会使用这些名字来连接另一个将名字存储为“姓氏、名字”的系统? ),以及你能承受多少惹恼你的用户。如果这是一个内部 HR 应用程序,您可能会惹恼用户很多,并且对名称组件进行非常结构化、正式的细分(有不止 3 个 - 不要忘记 mr/mrs, jr, III,多个中间名、带连字符的姓氏,如果您试图处理来自所有文化的名字,谁知道还有什么。

回答by Johnno Nolan

You may want to search on the 3 separate fields for one and its inexpensive to concatenate for the fullname.

您可能想在 3 个单独的字段中搜索一个,并且连接全名的成本很低。

e.g. If you want to search for all the Mr. Nolans your query would be

例如,如果您想搜索所有诺兰先生,您的查询将是

SELECT Title+' '+FirstName+' '+Surname As FullName  
from table where firstname = 'Mr' and surname ='Nolan'

to do this with just the fullnames would be a pain.

只用全名来做到这一点会很痛苦。

回答by Ken Keenan

Keeping the fields separate allows you to support different output formats and cultures where the family name is written first

保持字段分开允许您支持首先写入姓氏的不同输出格式和文化

回答by bobobobo

Things like ORDER BY firstnameor ORDER BY lastnameare possible when you break the name up into multiple fields.

当您将名称分解为多个字段时,可能会出现类似ORDER BY firstnameORDER BY lastname可能的情况。

Not as easy to do when you mash all names into one field.

当您将所有名称混合到一个字段中时,这并不容易。

回答by Wookey

I'm English and only have one name. I normally put it in the 'surname' field for least aggravation. I am usually forced to put something in the 'first name' field too, which by definition is wrong.

我是英国人,只有一个名字。我通常把它放在“姓氏”字段中,以免加重病情。我通常也被迫在“名字”字段中放一些东西,这从定义上来说是错误的。

Any attempt to impose anything more than 'Name' is doomed to be wrong at least some of the time, and sometimes be very frustrating to users. Single names are common in Southern India, Indonesia, and Pakistan (which is hundreds of millions of people) as well as the occaisional weirdo on the UK like me.

任何强加任何比“名称”更多的尝试至​​少在某些时候注定是错误的,有时会让用户感到非常沮丧。在印度南部、印度尼西亚和巴基斯坦(有数亿人口)以及像我这样的英国偶尔出现的怪人中,单名很常见。

The 'first, middle, last' thing is very U.S.-centric. Few other countries think of names that way. Please stop doing it.

“第一、中间、最后”这件事非常以美国为中心。很少有其他国家会以这种方式考虑名称。请停止这样做。

回答by Wedge

Here's the thing, not even humans can get this right all the time, there's just too much data, and too many special cases. I could change my name right now to be 20 parts, with the middle 13 as my "first" name. Parts of names can contain any number of words, and there can be any number of parts of names. Some people only have 1 name (no surname). Some people have lots of middle names. Some people have first or surnames composed of several words. Some people list their surname first. Some people go by their middle name. Some people go by nicknames that aren't obviously related to their given name.

事情就是这样,即使是人类也无法一直做到这一点,数据太多,特殊情况太多。我现在可以把我的名字改成 20 个部分,中间的 13 个是我的“名字”。名称的部分可以包含任意数量的单词,并且名称可以有任意数量的部分。有些人只有一个名字(没有姓氏)。有些人有很多中间名。有些人的名字或姓氏由几个词组成。有些人首先列出他们的姓氏。有些人用他们的中间名。有些人使用与他们的名字没有明显关系的昵称。

If you try to guess these conventions in software YOU WILL FAIL. Period. Maybe you'll get it right some of the time, maybe even most of the time, but is even that worth it? In my opinion you should store names as one field and stop trying to be cute by using first names to refer to a person. If you need additional information about a name (e.g. a nickname), ask the user!

如果您试图在软件中猜测这些约定,您将失败。时期。也许你会在某些时候,甚至大部分时间都做对,但这是否值得?在我看来,您应该将姓名存储为一个字段,不要试图通过使用名字来指代一个人来变得可爱。如果您需要有关姓名的其他信息(例如昵称),请询问用户!