[英]Normalization of an address table advice needed
Hope this is an acceptable question as not a programming question as such. 希望这是一个可以接受的问题,而不是编程问题。
I have a database with several tables 我有几个表的数据库
Student Teacher Parents Staff 学生老师家长职员
All need to have a reference to an address table 所有都需要参考地址表
Address - door number - street - town - city - postcode 地址-门号-街道-城镇-城市-邮政编码
My question is :- 我的问题是:
How can I create a address table with little duplication of data. 如何创建很少重复数据的地址表。 Is the only way to have separate tables tables for each?
是每个表都有单独的表的唯一方法吗?
Hope you guys can advise. 希望你们能提供建议。
Have a separate Address table with the following columns 有一个单独的地址表,其以下各列
address_id
door_number
street
town
city
state
country
postcode
Now in each of the tables - Student , Parent , Teacher , Staff - have an address_id column and create a foreign key to the address_id in the address table. 现在在每个表(Student,Parent,Teacher,Staff)中都有一个address_id列,并在地址表中创建到address_id的外键。
Assuming Student and Parent are already related, you can have the address just in the Parents table. 假设“学生”和“父母”已经相关,则可以在“父母”表中输入地址。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.