View difference between Paste ID: N7i5LWwg and V0V3VBLZ
SHOW: | | - or go back to the newest paste.
1
foreign(T, U, Attrs) :-
2
    foreign_claim(T, U, Attrs),
3
    forall(member(A, Attrs), (attribute(A, T),
4
			      attribute(A, U))),
5
    T\=U.
6
7
foreign_key_path(T, T, []) :-
8
    table(T).
9
10
foreign_key_path(T, U, [foreign(T, U, Attrs)]) :-
11
    foreign(T, U, Attrs).
12
13
foreign_key_path(T, V, [foreign(T, U, Attrs) | Rest]) :-
14
    foreign(T, U, Attrs),
15
    foreign_key_path(U, V, Rest).
16
17
attribute(custkey, customer).
18
attribute(name, customer).
19
attribute(address, customer).
20
attribute(nationkey, customer).
21
attribute(phone, customer).
22
attribute(acctbal, customer).
23
attribute(mktsegment, customer).
24
attribute(comment, customer).
25
26
attribute(nationkey, nation).
27
attribute(name, nation).
28
attribute(regionkey, nation).
29
attribute(comment, nation).
30
31
attribute(regionkey, region).
32
attribute(name, region).
33
attribute(comment, region).
34
35
key_claim([custkey], customer).
36
foreign_claim(customer, nation, [nationkey]).
37-
foreign_claim(nation, region, [regionkey]).
37+
foreign_claim(nation, region, [regionkey]).
38
39
%%%%%
40
41
| ?- setof(Z, foreign_key_path(_, _, Z), L).
42
setof(Z, foreign_key_path(_, _, Z), L).
43
44
L = [[]] ? ;
45
46
L = [[foreign(customer,nation,[nationkey])]] ? ;
47
48
L = [[foreign(customer,nation,[nationkey]),foreign(nation,region,[regionkey])]] ? ;
49
50
L = [[]] ? ;
51
52
L = [[foreign(nation,region,[regionkey])]] ? ;
53
54
L = [[]]
55
56
%%%%%
57
58
I want instead a second L being the union of all of the above results.