我如何正确引用表格 [英] How do I properly reference tables
问题描述
我有桌子的人存储有关一个人的所有信息。
另一个表联系人存储关于桌面人的联系信息。
联系人有contactid栏,这是从表人员引用。
另一个表紧急联系人,存储一个人的紧急联系人。
如何实现以下目标
1. personA的紧急联系人 - (personB)可能已经存在于Person表中,他们也有联系信息。当删除personB联系信息时,应删除紧急表中的引用,并在更新personB的联系信息时级联。
2. personA的紧急联系人可能尚未存在于表人员中。
谢谢。
I have tables person which stores all information about a person.
Another table contact which stores contact info about table person.
Contact has column "contactid" which is referenced from table person.
And another table " emergency contacts" which stores emergency contacts of a person.
How do I achieve the following
1. the emergency contact of personA -(personB) may already exist in Person table who also have contact info. When personB contact info is deleted the reference in emergency table should be delete and also cascade upon update of personB's contact info.
2.the emergency contact of personA may not already exist in table Person.
Thanks.
推荐答案
有一个人员表来存储所有人和一个表来存储所有引用。在删除人员记录之前,请删除所有参考文件。
Have one person table to store all people and one table to store all the references. Before deleting a person record, delete all the references.
Person
Name ...
Alice ...
Bob ...
Reference
From To ...
Alice Bob ...
(我永远不会使用名称(或其他字符串)作为ID,但你明白了。)
参考表还可以包含指示什么类型的参考它是 - 例如紧急联系人,或授权买家,或任何你需要的。
(I would never use names (or other strings) as IDs, but you get the idea.)
The reference table can also hold an indicator of what type of reference it is -- such as emergency contact, or authorized buyer, or whatever you need.
这篇关于我如何正确引用表格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!