如何将手机号码存储在数据库中?

发布于 2024-07-09 05:10:07 字数 308 浏览 8 评论 0原文

随着短信和类似事物的时代,在数据库中存储电话号码的好方法是什么?

在美国,短信是通过电话号码处理的,但在其他国家/地区,我听说他们使用电子邮件地址,因此我想需要有一种方法来区分使用手机号码作为地址的国家/地区。

添加: 例如,美国人可能会使用 432-342-3333 或 1-432-342-3333,而在英国,他们可能会使用 +44 800 400000,甚至可能省略 44。44 和 1 是有区别的自动发送短信时。 然而,检查每个国家/地区的电话号码可能会很乏味。 在这种情况下,您会拆分国家/地区代码还是将其合并到单个列中并在那里进行处理?

With the age of text messages and things like that, what's a good way to store phone numbers in a database?

In the USA, text messages are handled by phone numbers but in other countries I hear they use email addresses so I guess there needs to be a way to differentiate between countries that use cell phone numbers as their address.

Addition:
For example, people in the USA might use 432-342-3333 or 1-432-342-3333 while in the UK they might use +44 800 400000 or they might even leave out the 44. The 44 and the 1 makes a difference when automatically sending out SMS. However, checking the phone number for each country can get tedious. In this case, would you split the country code or would you merge it into a single column and deal it with it there?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

倒带 2024-07-16 05:10:07

我主要使用一个文本字段或一系列文本字段,即使您出于以下原因使用数字电话号码也是如此。

  1. 电话号码的值范围很大,包括分机号码,这可能会导致数字列失去精度。
  2. 失去电话号码的精确度是相当糟糕的。
  3. 没有逻辑理由想要对电话号码执行数学(加法/乘法)。

此外,您可能需要指定如何使用这些数据。 如果您正在计划自动消息传递服务,则将需要一系列中继代理来进行广播,因此您也可以添加与信息所属的中继相关的标识符。 那么您只需担心中继代理能否理解文本字段中的内容。

I would primarily use a text field, or a series of text fields, even if you are using a numerical phone number for the following reasons.

  1. Phone numbers have a great range of values, including extension numbers which may result in numerical columns losing precision.
  2. Losing precision in a phone number is rather bad.
  3. There is no logical reason to want to perform math ( addition/multiplication ) on a phone number.

Additionally, you may want to specify how you are using this data. If you are planning an automated messaging service, you're going to need a series of relaying agents to broadcast via, so you may as well add an identifier that pertains to the relay the information pertains to. Then all you have to worry about is that the relaying agent can understand the content in the text fields.

御守 2024-07-16 05:10:07

一般来说,作为文本,您不需要所有花哨的格式,除非您需要它来解析来自不同国家/地区的数字,否则您无法区分。 您以后随时可以添加格式。

不是一个数字!!! 前导零可能会出现问题。

Generally as text, you don't need all the fancy formatting, unless you need it to parse numbers from different countries that you can't distinguish otherwise. You can always add the formatting later on.

Not as a number!!! Leading zeros may be problematic.

窗影残 2024-07-16 05:10:07

我不知道你是否读过这两个问题,但它们可能对你有一点帮助。

也许明智的做法是存储号码类型(固定电话、手机、传真)和/或可以通过其接收的消息(语音、文本、电子邮件)。 请注意,在美国,也可以通过电子邮件向手机发送短信,但我认为这取决于运营商。

I don't know if you have read these two questions, but they might help you a little.

Perhaps it would be wise to store the type of number (landline, cell, fax) and/or the messages that can be received on it (voice, text, email). Note that in the US, it is also possible to send text messages to a phone via email, but I believe that is dependent on the carrier.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文