nrdatalog2sql
nrdatalog2sql copied to clipboard
Clarification on parameters
Hi @ghxiao,
I am working on a project called stypes which creates Non-recursive (NDL) datalog program from:
- a conjunctive query (CQ),
- the CQ tree decomposition
- and an ontology as a set of TGDs
I want to evaluate as SQL, and your nrdatalog2sql would be really useful for me. I tried to run nrdatalog2sql, but it requires:
- datalog.dl
- vocab.txt
I am not entirely sure how I can provide the vocabulary and datalog nrdatalog requires.
For example for a datalog NDL like: p1(x0,x7) :- p3(x0,x3), r(x3,x4), p12(x7,x4). p3(x0,x3) :- a(x0), r(x0,x3). p3(x0,x3) :- s(x0,x1), r(x1,x2), r(x2,x3). p12(x7,x4) :- r(x4,x5), r(x5,x6), s(x6,x7). p12(x7,x4) :- r(x4,x7), b(x7).
where the EDB are : { r(x,y), s(x,y) a(x), b(x) }
How can I use nrdatalog2sql
The SQL for the NDL above, which at the moment I do manually, should be something like:
select distinct p3.X as x, p12.X as y from ( select A.X, R.Y from A inner join R on A.X = R.X union select S.X, R2.Y from S inner join R as R1 on S.Y = R1.X inner join R as R2 on R1.Y = R2.X ) as p3 inner join R on p3.Y = R.X inner join ( select S.Y as X, R1.X as Y from R as R1 inner join R as R2 on R1.Y = R2.X inner join S on R2.Y = S.X union select B.X as X, R.X as Y from R inner join B on R.Y = B.X ) as p12 on R.Y = p12.Y
It would be handy if I can use nrdatalog to convert NDL to SQL easily. If it requires some changes, I am happy to collaborate with you in improving it further.