什么是“最好的"?如何在数据库中存储国际地址? [英] What is the "best" way to store international addresses in a database?

查看:17
本文介绍了什么是“最好的"?如何在数据库中存储国际地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在数据库中存储国际地址的最佳"方式是什么?以模式的形式回答,并解释您选择规范化(或不规范化)方式的原因.还要说明您选择每个字段的类型和长度的原因.

What is the "best" way to store international addresses in a database? Answer in the form of a schema and an explanation of the reasons why you chose to normalize (or not) the way you did. Also explain why you chose the type and length of each field.

注意:您决定您认为哪些字段是必要的.

推荐答案

纯自由格式文本.

验证世界上所有的邮政编码太难了;固定的国家名单在政治上过于敏感;强制性的州/地区/其他行政区划完全不合适(我经常被问到我住在哪个县——其实我没有,因为大伦敦根本不是一个县).

Validating all the world's post/zip codes is too hard; a fixed list of countries is too politically sensitive; mandatory state/region/other administrative subdivision is just plain inappropriate (all too often I'm asked which county I live in--when I don't, because Greater London is not a county at all).

更重要的是,这根本没有必要.您的应用程序极不可能以任何严肃的方式对地址进行建模.如果您想要邮政地址,请询问邮政地址.大多数人不会傻到输入邮政地址以外的其他东西,如果他们这样做了,他们就可以亲吻他们新购买的物品了.

More to the point, it's simply unnecessary. Your application is highly unlikely to be modelling addresses in any serious way. If you want a postal address, ask for the postal address. Most people aren't so stupid as to put in something other than a postal address, and if they do, they can kiss their newly purchased item bye-bye.

例外情况是,如果您所做的事情无论如何都自然受限于某个国家/地区.在这种情况下,您应该询问,例如,{ postcode, house number } 对,这足以识别邮政地址.我想你可以通过美国的扩展邮政编码实现类似的目标.

The exception to this is if you're doing something that's naturally constrained to one country anyway. In this situation, you should ask for, say, the { postcode, house number } pair, which is enough to identify a postal address. I imagine you could achieve similar things with the extended zip code in the US.

这篇关于什么是“最好的"?如何在数据库中存储国际地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆