我正在通过制作代表FK依赖项然后穿越图形的有向图来对我们的表进行一些FK分析。在我的代码中,我使用定向图术语命名所有内容,但是我想在报告中有一些“用户友好”的东西。

在这种情况下:

create table t1(a varchar2(20));
alter table t1 add constraint t1_fk foreign key(a) references t2(b);

t1.a 必须存在于 t2.b 中。那么,空白处应该用什么词呢?

t1 is the _______ of t2.
t2 is the _______ of t1.

很多TIA!

有帮助吗?

解决方案

我会说(括号内的东西是可选的,但我会使用它们)

[Column a of] table t1 references [column b of] table t2

[Column b of] table t2 is referenced by [column a of] table t1

我还会指定删除/更新时发生的操作(如果有的话)。

Column b of table t2 is referenced by column a of table t1. 
Deleting a record in table t2 will delete matching records on table t1

其他提示

t1 is the parent of t2.
t2 is the child of t1.

这是什么观众?如果是理解关系模式的人,那么可能会这样做。如果它是非技术人员,那么我通常会在我的建模工具(ERWin)中记录具体关系的含义。

InvoiceLineItem is a part of Invoice.
Invoice has one or more InvoiceLineItems.

或者:

User must belong to a Business.
Business has zero or more Users.

我会说

t1 is the master of t2. An ID must be in t1, before it can be mentioned in t2.
t2 is the slave of t1. It cannot refer to an ID that does not exist in t1.

大多数非技术人员会非常直观地掌握主/从术语。

你可以采用下面的句子形式:

  • 每个 t1 行必须恰好链接到一个 t2 行
  • 每个 t2 行可以与任意数量的 t1 行链接,也可以不链接

在解释的场景中,我认为正确的命名应该是(从技术上讲):
t2 t1
的父代 t1 t2

的子代

受约束列的表称为,而引用列的表称为 parent

我个人不喜欢这个命名,在SQL SERVER中查询 sys.foreign_keys 视图时,子表被称为 parent_object_id ,而引用的表被称为<代码> referenced_object_id ..从约束本身的角度来看,可能是正确的......但最后这是非常令人困惑的。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top