Guest User

Untitled

a guest
Jun 20th, 2013
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.96 KB | None | 0 0
  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]).
Advertisement
Add Comment
Please, Sign In to add comment