在关系数据库中查找“一对三”链接

Finding "1-to-3" links in a relational database

我敢肯定有一个我不知道的术语,但我们称之为寻找“1 对 3”link。假设我有一个像这样的 table:

ID  Src     Src_Field  Tgt      Tgt_Field
1   Table1  Field_A    Table2   Field_D
2   Table1  Field_B    Table2   Field_E
3   Table1  Field_C    Table2   Field_F
4   Table2  Field_D    Table3   Field_G
5   Table2  Field_E    Table3   Field_H
6   Table2  Field_F    Table3   Field_I

我希望最终结果如下所示:

Table1  Field_A Table2  Field_D Table3  Field_G
Table1  Field_B Table2  Field_E Table3  Field_H
Table1  Field_C Table2  Field_F Table3  Field_I

我不是在找人帮我写查询,而是在找这个叫什么,算法的 link 等。我正在努力寻找这些links 并将它们配对:

1 => 2
2 => 3

所以我得到:

1 => 2 => 3

因此我的术语是“一对三”link。实际的关系数据库并不重要。我主要是想了解如何执行此操作。

我将其描述为 hierarchical database model

A hierarchical database model is a data model in which the data is organized into a tree-like structure.

A​​ recursive join 将用于获取您提供的结果。

The recursive join is an operation used in relational databases, also sometimes called a "fixed-point join". It is a compound operation that involves repeating the join operation, typically accumulating more records each time, until a repetition makes no change to the results (as compared to the results of the previous iteration).