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
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