算法3:子程序VarJoinsRefinement(σ, x)

输入:一个待优化的tgd σ和一个来自于σ的变量x

输出:一组已经连接优化完毕的tgds Σ'

1: 初始化σ得到σ'

2: let σ' = φ' → ψ'

3: Ccand ← generate set of possibles candidates from σ'

4: Cv ←∅

5: repeat

6: P ← SelectPartition(Ccand, Cv)

7: σ'' ← UnifyVariables(σ', P)

8: if AskJoinsValidity(σ'') then

9: add P to Cv

10: remove P and its More rough partitions from Ccand

11: else

12: remove P from Ccand

13: end if

14: until Ccand =∅

15: Σ' ←∅

16: for all P∈Cv do

17: σ'' ← UnifyVariables(σ', P)

18: add σ'' to Σ'

19: end for

20: return Σ'