这是用于手持手机/传真/等的常见设计。数字。每个用户都可以根据需要拥有尽可能多的移动/传真/电话记录。您可能想要更改号码表,在美国,电话号码如下所示:1-234-567-9876。是1
国家代码,234
是“区号”,567
是“交易所”,9876
是“站”。我使用char
数据类型以防我必须存储带有前导 0 的数字。
number_types
id unsigned int(P)
description varchar(15)
+----+-------------+
| id | description |
+----+-------------+
| 1 | Mobile |
| 2 | Phone |
| 3 | Fax |
| .. | ........... |
+----+-------------+
numbers
id unsigned int(P)
country_code char(3)
area_code char(3)
exchange char(3)
station char(4)
extension varchar(10) // Default to NULL
+----+--------------+-----------+----------+---------+-----------+
| id | country_code | area_code | exchange | station | extension |
+----+--------------+-----------+----------+---------+-----------+
| 1 | 98 | 21 | 555 | 5555 | NULL |
| 1 | 01 | 555 | 555 | 5555 | NULL |
| .. | ............ | ......... | ........ | ....... | ......... |
+----+--------------+-----------+----------+---------+-----------+
users
id unsigned int(P)
first_name varchar(30)
last_name varchar(30)
...
+----+------------+-----------+-----+
| id | first_name | last_name | ... |
+----+------------+-----------+-----+
| 1 | Saroukhani | Smith | ... |
| 2 | Benny | Hill | ... |
| .. | .......... | ......... | ... |
+----+------------+-----------+-----+
users_numbers
id unsigned int(P)
user_id unsigned int(F users.id)
number_id unsigned int(F numbers.id)
number_type_id unsigned int(F number_types.id)
+----+---------+-----------+----------------+
| id | user_id | number_id | number_type_id |
+----+---------+-----------+----------------+
| 1 | 1 | 1 | 1 |
| 2 | 2 | 2 | 1 |
| .. | ....... | ......... | .............. |
+----+---------+-----------+----------------+