INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Finding associations

Finding associations

(OP)
Hello
Newbie to Prolog - never used it yet! - however, looks interesting.

I was wondering if Prolog can be used to solve my query below. I write many many queries in sql
and it would be great if I could select a known field and something like Prolog could throw out the tables and joins referring to a given field.

For example - assume the following query ............
select
table1.name,
table4.currency
from
table1
inner join table2 on table1.id = table2.id and table1.ref = table2.ref
inner join table3 on table2.ref = table3.ref
inner join table4 on table1.id = table4.id

Is there a way in Prolog to show Ancestors and Predecessors when I ask the question something like ...
?- table4.currency
I would like to see an output something like .....

table2 on table1.id = table2.id and table1.ref = table2.ref,
table3 on table2.ref = table3.ref,
inner join table4 on table1.id = table4.id

.. as these are the tables required to get to table4.currency

equally - if I ask a different question of Prolog - eg
?- table1.name
I would still like to see all the tables and joins associated with this field - so, the output would still be the same
table2 on table1.id = table2.id and table1.ref = table2.ref,
table3 on table2.ref = table3.ref,
inner join table4 on table1.id = table4.id

Hope the above makes some sort of sense and if possible what would be the intial structure be like in order to throw
questions at it via Prolog.

Regards
Phil

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close