如何将手机号码存储在数据库中?
随着短信和类似事物的时代,在数据库中存储电话号码的好方法是什么?
在美国,短信是通过电话号码处理的,但在其他国家/地区,我听说他们使用电子邮件地址,因此我想需要有一种方法来区分使用手机号码作为地址的国家/地区。
添加: 例如,美国人可能会使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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.
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.
一般来说,作为文本,您不需要所有花哨的格式,除非您需要它来解析来自不同国家/地区的数字,否则您无法区分。 您以后随时可以添加格式。
不是一个数字!!! 前导零可能会出现问题。
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.
我不知道你是否读过这两个问题,但它们可能对你有一点帮助。
也许明智的做法是存储号码类型(固定电话、手机、传真)和/或可以通过其接收的消息(语音、文本、电子邮件)。 请注意,在美国,也可以通过电子邮件向手机发送短信,但我认为这取决于运营商。
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.