在数据库(RDBMS)中存储邮政地址的最佳做法? [英] Best practices for storing postal addresses in a database (RDBMS)?

查看:133
本文介绍了在数据库(RDBMS)中存储邮政地址的最佳做法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在RDBMS中存储邮政地址的最佳做法是否有很好的参考?看来有很多的折衷,可以做出很多的利弊,每个要评价 - 肯定这已经一次又一次地完成了吗?也许有人至少已经写过一些经验教训在某个地方?

Are there any good references for best practices for storing postal addresses in an RDBMS? It seems there are lots of tradeoffs that can be made and lots of pros and cons to each to be evaluated -- surely this has been done time and time again? Maybe someone has at least written done some lessons learned somewhere?

我所说的折衷例子是存储邮政编码作为一个整数对一个字段,存储为单独的字段或地址线1的一部分,应该将套房/公寓/等号码归一化或仅作为文本块存储在地址线2中,如何处理zip +4(单独的字段或一个大字段,整数对文本)?等等。

Examples of the tradeoffs I am talking about are storing the zipcode as an integer vs a char field, should house number be stored as a separate field or part of address line 1, should suite/apartment/etc numbers be normalized or just stored as a chunk of text in address line 2, how do you handle zip +4 (separate fields or one big field, integer vs text)? etc.

我主要关心美国的地址,但我想,有一些最好的做法,在准备自己的全球性的可能性

I'm primarily concerned with U.S. addresses at this point but I imagine there are some best practices in regards to preparing yourself for the eventuality of going global as well (e.g. naming fields appropriately like region instead of state or postal code instead of zip code, etc.

推荐答案

作为国际用户,没有什么更令人沮丧的是,处理一个只针对美国格式地址的网站,这是一个有点粗鲁,但成为一个严重的问题,当验证也过热。

As an 'international' user, there is nothing more frustrating than dealing with a website that is oriented around only US-format addresses. It's a little rude at first, but becomes a serious problem when the validation is also over-zealous.

如果你关心全球化,我唯一的建议是保持自由形式不同的国家有不同的约定 - 在一些,房子号码在街道名称之前,在某些在这里,在英国,邮政编码不是邮政编码,它是一个包含字母和数字的邮政编码。

If you are concerned with going global, the only advice I have is to keep things free-form. Different countries have different conventions - in some, the house number comes before the street name, in some it comes after. Some have states, some regions, some counties, some combinations of those. Here in the UK, the zipcode is not a zipcode, it's a postcode containing both letters and numbers.

我建议简单的〜10行可变长度的字符串,以及一个单独的字段为一个邮政编码(并且要小心如何描述,以应对国家的敏感性)。让用户/客户决定如何写他们的地址。

I'd advise simply ~10 lines of variable-length strings, together with a separate field for a postcode (and be careful how you describe that to cope with national sensibilities). Let the user/customer decide how to write their addresses.

这篇关于在数据库(RDBMS)中存储邮政地址的最佳做法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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