You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by tina sani <ti...@gmail.com> on 2017/08/24 07:50:05 UTC
SPARQL vs Jena rules
What are some of advantages of SPARQL over (Jena) rules? I know only that
SPARQL is W3C recommendation and jena rules are not. Similarly, Jena rules
are monotonic which does not add/remove any data just infer new knowledge.
How SPARQL is more expressive than rules?
If we get some inference using SPARQL, how it differs (better) than
inference using rules.
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
<#m_-5991634784996563873_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
Re: SPARQL vs Jena rules
Posted by Martynas Jusevičius <ma...@atomgraph.com>.
One main point to consider is that rules are Jena-specific, while SPARQL is
standard and portable.
On Fri, Aug 25, 2017 at 12:57 PM, tina sani <ti...@gmail.com> wrote:
> Thank you Lorenz.
>
> We are working on different small projects. Currently, how to get inference
> (as Jena rule do) from CONSTRUCT query and why the inference of CONSTRUCT
> is better than Jena rules.
>
> On Fri, Aug 25, 2017 at 12:52 PM, Lorenz Buehmann <
> buehmann@informatik.uni-leipzig.de> wrote:
>
> > You should try to talk to and collaborate with your team members, Javed
> > Khan and Sidrah Shah...
> >
> > Next, you're comparing a query language with a rule engine - those are
> > obviously different things (although you can do some things also in
> > SPARQL that you can do with Jena rules.)
> >
> > Regarding performance, there is no answer. Obviously in Jena both is
> > executed in Java probably using some shared Jena core functionalities.
> > Nevertheless, there is no need for comparison.
> >
> > The question that comes up here in the mailing list - why are you still
> > asking those basic questions? What is the task of the project? I
> > remember that you used Jena rules all the time - now you're think about
> > using SPARQL? Why? Inferencing and querying are totally different
> > things. So why are you thinking about refactoring the whole project? How
> > much time do you need for this academic project? I mean, it sounds like
> > you're working on it for almost one year now? Is this really necessary
> > and useful to spend so much time on it?
> >
> >
> > Lorenz
> >
> >
> > On 24.08.2017 13:25, tina sani wrote:
> > > Andy, I need some points in which SPARQL query can be better than rules
> > to
> > > get the desired result?
> > >
> > > Is it fast (in terms of time) than jena rules to be executed by the
> > engine?
> > > Second, in terms of expressiveness, how SPARQL is better than the
> rules?
> > > One point I think is jena rules does not support dis-junction while
> > SPARQL
> > > does (UNION). ,
> > >
> > > On Thu, Aug 24, 2017 at 2:07 PM, Andy Seaborne <an...@apache.org>
> wrote:
> > >
> > >> This has been asked before, most recently 2017-08-14.
> > >>
> > >> https://lists.apache.org/thread.html/ae4c1f5dfbacfb9bf4294a4
> > >> cf2967e0c7050c81b20f80e6c425a9aa8@%3Cusers.jena.apache.org%3E
> > >>
> > >> Please search the archives before asking questions.
> > >>
> > >> Andy
> > >>
> > >> On 24/08/17 08:50, tina sani wrote:
> > >>
> > >>> What are some of advantages of SPARQL over (Jena) rules? I know only
> > that
> > >>> SPARQL is W3C recommendation and jena rules are not. Similarly, Jena
> > rules
> > >>> are monotonic which does not add/remove any data just infer new
> > knowledge.
> > >>> How SPARQL is more expressive than rules?
> > >>>
> > >>> If we get some inference using SPARQL, how it differs (better) than
> > >>> inference using rules.
> > >>>
> > >>> <https://www.avast.com/sig-email?utm_medium=email&utm_source
> > >>> =link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
> > >>> Virus-free.
> > >>> www.avast.com
> > >>> <https://www.avast.com/sig-email?utm_medium=email&utm_source
> > >>> =link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> > >>> <#m_-5991634784996563873_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> > >>>
> > >>>
> >
> >
>
Re: SPARQL vs Jena rules
Posted by tina sani <ti...@gmail.com>.
Hello Lorenz, thank you for your detailed response.
I know Construct query can not be the alternative of Jena rules, may be
not better than it either. But SPARQL is W3C recommended and provide
disjunction in shape of UNION which Jena rules dont. . Also, we can delete
new knowledge inferred using SPARQL which we cant using Jena rules, due to
its monotonic nature.
In my previous project, rules created problem for me ( and for some of my
mates) when the rules fired and generated new triples but I was unable to
delete it again because rules are monotonic.
Currently, I am on a project to study how much "inference " we can get via
CONSTRUCT query, if we dont use rules or make its use limited .
On Fri, Aug 25, 2017 at 5:35 PM, Lorenz Buehmann <
buehmann@informatik.uni-leipzig.de> wrote:
>
>
>
> > how to get inference
> > (as Jena rule do) from CONSTRUCT query
> You should really start to understand how a rule engine works. (By the
> way, Apache Jena uses the RETE engine as core).
> And then, let me ask you some questions:
>
> * how are multiple rules processed?
> * what happens if one rule r1 "depends on" another rule r2, i.e. r2
> produces some triples that are used by r1?
> * what happens if there are cyclic dependencies?
>
> Once you answered those questions, think about how a single SPARQL query
> can resp. should solve this problem?
> > and why the inference of CONSTRUCT
> > is better than Jena rules.
> How do you come to this conclusion? Or why do you think so? Did somebody
> tell you this? You should start with the comparison of the
> expressiveness of SPARQL vs. a rule engine - by the way, Apache Jena
> rules is not a standardized rule language.
> What about recursion in rules? For example, SPARQL 1.0 can be translated
> from/to nonrecursive Datalog with negation.
>
> Again, why do you compare those two Jena mechanisms? What is the
> expected outcome?
> >
> > On Fri, Aug 25, 2017 at 12:52 PM, Lorenz Buehmann <
> > buehmann@informatik.uni-leipzig.de> wrote:
> >
> >> You should try to talk to and collaborate with your team members, Javed
> >> Khan and Sidrah Shah...
> >>
> >> Next, you're comparing a query language with a rule engine - those are
> >> obviously different things (although you can do some things also in
> >> SPARQL that you can do with Jena rules.)
> >>
> >> Regarding performance, there is no answer. Obviously in Jena both is
> >> executed in Java probably using some shared Jena core functionalities.
> >> Nevertheless, there is no need for comparison.
> >>
> >> The question that comes up here in the mailing list - why are you still
> >> asking those basic questions? What is the task of the project? I
> >> remember that you used Jena rules all the time - now you're think about
> >> using SPARQL? Why? Inferencing and querying are totally different
> >> things. So why are you thinking about refactoring the whole project? How
> >> much time do you need for this academic project? I mean, it sounds like
> >> you're working on it for almost one year now? Is this really necessary
> >> and useful to spend so much time on it?
> >>
> >>
> >> Lorenz
> >>
> >>
> >> On 24.08.2017 13:25, tina sani wrote:
> >>> Andy, I need some points in which SPARQL query can be better than rules
> >> to
> >>> get the desired result?
> >>>
> >>> Is it fast (in terms of time) than jena rules to be executed by the
> >> engine?
> >>> Second, in terms of expressiveness, how SPARQL is better than the
> rules?
> >>> One point I think is jena rules does not support dis-junction while
> >> SPARQL
> >>> does (UNION). ,
> >>>
> >>> On Thu, Aug 24, 2017 at 2:07 PM, Andy Seaborne <an...@apache.org>
> wrote:
> >>>
> >>>> This has been asked before, most recently 2017-08-14.
> >>>>
> >>>> https://lists.apache.org/thread.html/ae4c1f5dfbacfb9bf4294a4
> >>>> cf2967e0c7050c81b20f80e6c425a9aa8@%3Cusers.jena.apache.org%3E
> >>>>
> >>>> Please search the archives before asking questions.
> >>>>
> >>>> Andy
> >>>>
> >>>> On 24/08/17 08:50, tina sani wrote:
> >>>>
> >>>>> What are some of advantages of SPARQL over (Jena) rules? I know only
> >> that
> >>>>> SPARQL is W3C recommendation and jena rules are not. Similarly, Jena
> >> rules
> >>>>> are monotonic which does not add/remove any data just infer new
> >> knowledge.
> >>>>> How SPARQL is more expressive than rules?
> >>>>>
> >>>>> If we get some inference using SPARQL, how it differs (better) than
> >>>>> inference using rules.
> >>>>>
> >>>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source
> >>>>> =link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
> >>>>> Virus-free.
> >>>>> www.avast.com
> >>>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source
> >>>>> =link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> >>>>> <#m_-5991634784996563873_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >>>>>
> >>>>>
> >>
>
>
Re: SPARQL vs Jena rules
Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
> how to get inference
> (as Jena rule do) from CONSTRUCT query
You should really start to understand how a rule engine works. (By the
way, Apache Jena uses the RETE engine as core).
And then, let me ask you some questions:
* how are multiple rules processed?
* what happens if one rule r1 "depends on" another rule r2, i.e. r2
produces some triples that are used by r1?
* what happens if there are cyclic dependencies?
Once you answered those questions, think about how a single SPARQL query
can resp. should solve this problem?
> and why the inference of CONSTRUCT
> is better than Jena rules.
How do you come to this conclusion? Or why do you think so? Did somebody
tell you this? You should start with the comparison of the
expressiveness of SPARQL vs. a rule engine - by the way, Apache Jena
rules is not a standardized rule language.
What about recursion in rules? For example, SPARQL 1.0 can be translated
from/to nonrecursive Datalog with negation.
Again, why do you compare those two Jena mechanisms? What is the
expected outcome?
>
> On Fri, Aug 25, 2017 at 12:52 PM, Lorenz Buehmann <
> buehmann@informatik.uni-leipzig.de> wrote:
>
>> You should try to talk to and collaborate with your team members, Javed
>> Khan and Sidrah Shah...
>>
>> Next, you're comparing a query language with a rule engine - those are
>> obviously different things (although you can do some things also in
>> SPARQL that you can do with Jena rules.)
>>
>> Regarding performance, there is no answer. Obviously in Jena both is
>> executed in Java probably using some shared Jena core functionalities.
>> Nevertheless, there is no need for comparison.
>>
>> The question that comes up here in the mailing list - why are you still
>> asking those basic questions? What is the task of the project? I
>> remember that you used Jena rules all the time - now you're think about
>> using SPARQL? Why? Inferencing and querying are totally different
>> things. So why are you thinking about refactoring the whole project? How
>> much time do you need for this academic project? I mean, it sounds like
>> you're working on it for almost one year now? Is this really necessary
>> and useful to spend so much time on it?
>>
>>
>> Lorenz
>>
>>
>> On 24.08.2017 13:25, tina sani wrote:
>>> Andy, I need some points in which SPARQL query can be better than rules
>> to
>>> get the desired result?
>>>
>>> Is it fast (in terms of time) than jena rules to be executed by the
>> engine?
>>> Second, in terms of expressiveness, how SPARQL is better than the rules?
>>> One point I think is jena rules does not support dis-junction while
>> SPARQL
>>> does (UNION). ,
>>>
>>> On Thu, Aug 24, 2017 at 2:07 PM, Andy Seaborne <an...@apache.org> wrote:
>>>
>>>> This has been asked before, most recently 2017-08-14.
>>>>
>>>> https://lists.apache.org/thread.html/ae4c1f5dfbacfb9bf4294a4
>>>> cf2967e0c7050c81b20f80e6c425a9aa8@%3Cusers.jena.apache.org%3E
>>>>
>>>> Please search the archives before asking questions.
>>>>
>>>> Andy
>>>>
>>>> On 24/08/17 08:50, tina sani wrote:
>>>>
>>>>> What are some of advantages of SPARQL over (Jena) rules? I know only
>> that
>>>>> SPARQL is W3C recommendation and jena rules are not. Similarly, Jena
>> rules
>>>>> are monotonic which does not add/remove any data just infer new
>> knowledge.
>>>>> How SPARQL is more expressive than rules?
>>>>>
>>>>> If we get some inference using SPARQL, how it differs (better) than
>>>>> inference using rules.
>>>>>
>>>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source
>>>>> =link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
>>>>> Virus-free.
>>>>> www.avast.com
>>>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source
>>>>> =link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
>>>>> <#m_-5991634784996563873_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>>>
>>>>>
>>
Re: SPARQL vs Jena rules
Posted by tina sani <ti...@gmail.com>.
Thank you Lorenz.
We are working on different small projects. Currently, how to get inference
(as Jena rule do) from CONSTRUCT query and why the inference of CONSTRUCT
is better than Jena rules.
On Fri, Aug 25, 2017 at 12:52 PM, Lorenz Buehmann <
buehmann@informatik.uni-leipzig.de> wrote:
> You should try to talk to and collaborate with your team members, Javed
> Khan and Sidrah Shah...
>
> Next, you're comparing a query language with a rule engine - those are
> obviously different things (although you can do some things also in
> SPARQL that you can do with Jena rules.)
>
> Regarding performance, there is no answer. Obviously in Jena both is
> executed in Java probably using some shared Jena core functionalities.
> Nevertheless, there is no need for comparison.
>
> The question that comes up here in the mailing list - why are you still
> asking those basic questions? What is the task of the project? I
> remember that you used Jena rules all the time - now you're think about
> using SPARQL? Why? Inferencing and querying are totally different
> things. So why are you thinking about refactoring the whole project? How
> much time do you need for this academic project? I mean, it sounds like
> you're working on it for almost one year now? Is this really necessary
> and useful to spend so much time on it?
>
>
> Lorenz
>
>
> On 24.08.2017 13:25, tina sani wrote:
> > Andy, I need some points in which SPARQL query can be better than rules
> to
> > get the desired result?
> >
> > Is it fast (in terms of time) than jena rules to be executed by the
> engine?
> > Second, in terms of expressiveness, how SPARQL is better than the rules?
> > One point I think is jena rules does not support dis-junction while
> SPARQL
> > does (UNION). ,
> >
> > On Thu, Aug 24, 2017 at 2:07 PM, Andy Seaborne <an...@apache.org> wrote:
> >
> >> This has been asked before, most recently 2017-08-14.
> >>
> >> https://lists.apache.org/thread.html/ae4c1f5dfbacfb9bf4294a4
> >> cf2967e0c7050c81b20f80e6c425a9aa8@%3Cusers.jena.apache.org%3E
> >>
> >> Please search the archives before asking questions.
> >>
> >> Andy
> >>
> >> On 24/08/17 08:50, tina sani wrote:
> >>
> >>> What are some of advantages of SPARQL over (Jena) rules? I know only
> that
> >>> SPARQL is W3C recommendation and jena rules are not. Similarly, Jena
> rules
> >>> are monotonic which does not add/remove any data just infer new
> knowledge.
> >>> How SPARQL is more expressive than rules?
> >>>
> >>> If we get some inference using SPARQL, how it differs (better) than
> >>> inference using rules.
> >>>
> >>> <https://www.avast.com/sig-email?utm_medium=email&utm_source
> >>> =link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
> >>> Virus-free.
> >>> www.avast.com
> >>> <https://www.avast.com/sig-email?utm_medium=email&utm_source
> >>> =link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> >>> <#m_-5991634784996563873_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >>>
> >>>
>
>
Re: SPARQL vs Jena rules
Posted by Dave Reynolds <da...@gmail.com>.
> On Thu, 31 Aug 2017 09:48:51 +0200, Dave Reynolds
> <da...@gmail.com> wrote:
>> 1c. If your rules can't be stratified, i.e. one rule can indirectly
>> trigger itself, then it's more complex. In that case you would have to
>> e.g. run the set of SPARQL Updates repeatedly until nothing new is
>> deduced. Depending on the specifics of the rules and the data that may
>> be quite expensive and you would be better off with something Jena
>> rules. However, in some cases you may be able to use things like
>> SPARQL property paths to achieve the desired effect without have to
>> recurse.
On 31/08/17 14:23, baran.ha@gmail.com wrote:
> As a simple example to close this with a concrete thing:
>
> @prefix skos: <http://www.w3.org/2004/02/skos/core#> .
>
> [myrules5: (?x skos:subject ?y), (?y skos:broader ?z) -> (?x
> skos:subject ?z)]
>
> What would you give as the equivalent SPARQL Update?
So that's an example of a rule which affects itself so, as explained,
it's not necessary a single SPARQL update. However, that falls into the
"sometimes you can use path expressions" get out. So it would be
something like (untested):
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
INSERT {
?x skos:subject ?z
} WHERE {
?x skos:subject/skos:broader+ ?z
};
Dave
Re: SPARQL vs Jena rules
Posted by ba...@gmail.com.
On Thu, 31 Aug 2017 09:48:51 +0200, Dave Reynolds
<da...@gmail.com> wrote:
> On 30/08/17 15:10, baran.ha@gmail.com wrote:
>
>> PS: I wonder why Dave doesn't comment in this thread. Perhaps because
>> he thinks, Lorenz is ok, i myself cannot stand the low-level-knowledge
>> of the users in this thread or no matter what you do, by some heavy
>> data-input an app with InfModel would hang anyway? Lorenz is ofcourse
>> ok, but i 'guess' Jena users are also very curious about Dave's
>> comments...
>
> I didn't comment on this thread because, as Andy has already pointed
> out, this seems to be a repeat of a recent similar thread (on which I
> did comment). That in turn was a near repeat of another similar thread.
> All from the same group.
>
> Also I think Lorenz has covered it all, with admirable patience.
>
> However, in an attempt to clarify the trade-offs in more depth maybe the
> following would be helpful:
>
> When comparing a rule system against a set of SPARQL Update queries
> there are several factors that affect the trade-offs including (1) the
> specific nature of the rules/queries, (2) the data flow and, (3)
> preferences on syntax and machinery.
>
> 1a. For a single (forward) Jena rule then you can always achieve the
> same with a SPARQL Update. For a single set of input data then SPARQL
> has the benefit of being a standard [1] and offering better performance
> over a store like TDB. Conversely SPARQL is much richer than Jena rules
> so there are things that you could achieve with a single SPARQL Update
> query using, say, property paths that would require multiple Jena rules.
>
> 1b. If you have a set of rules, but they don't create loops/recursion,
> then you can "stratify" them into groups of rules than can be run one
> after the other. In that case, for a single set of input data, then
> again you can implement it as a sequence of SPARQL Updates with similar
> benefits.
>
> 1c. If your rules can't be stratified, i.e. one rule can indirectly
> trigger itself, then it's more complex. In that case you would have to
> e.g. run the set of SPARQL Updates repeatedly until nothing new is
> deduced. Depending on the specifics of the rules and the data that may
> be quite expensive and you would be better off with something Jena
> rules. However, in some cases you may be able to use things like SPARQL
> property paths to achieve the desired effect without have to recurse.
>
> 2. If you have a single data set and just want to run your rules on it
> then the above applies. If you are repeatedly adding new data and want
> to keep your deductions up to date then the Jena forward rules engine
> has the advantage that it keeps all the partial matches around. So
> addition of one more triple may cause a rule to fire without it having
> to search for all the other triples in the body. This is also why
> "recursive" rules work relatively efficiently.
>
> This doesn't apply if you delete data. In that case Jena rules have to
> start over and can't reuse state across data deletions.
>
> If you keeping changing your data but very rarely ask questions of it,
> and then only limited questions, then Jena back rules have advantages.
> The backward engine will only run the rules needed for the specific
> query. If that's a lot fewer than the overall rules then that should be
> cheaper than running a full forward deduction using SPARQL Updates. In
> this situation it may be possible to achieve the same effects through
> SPARQL query (not update) by query rewriting but that's a whole
> different ball game.
>
> 3. With Jena rules you have some prebuilt machinery for running the
> rules (InfGraphs and all that) and some support for externalizing the
> rules in separate files. With SPARQL you have to create all that (though
> it's easy) and you have a nicer syntax.
>
> So fundamentally, like all "X vs Y" questions it depends on the
> specifics of what you are trying to do.
>
> Dave
>
> [1] There is a standard for rules, RIF, but it is not aimed at
> particularly RDF processing and post-dates Jena rules.
************
Hello, thanks for the response, i hope very much some other Jena.users
have also had their conclusions.
My personal project-dependent view to
'Jena rules vs SPARQL queries'
was as described in my first posting to this thread:
'Offline', with Jena Rules, to prepare the input data for tdbloder so,
that i can 'simplfy' some queries of my Query-UI with a better performance
for my Fuseki-endusers:
A Jena-app with InfModel + Rules-List -> output RDF -> TDB/Fuseki -> A
Query-UI
-------------------------------------------------------------------------------
Further assume Rules-List contains forward rules and only for this
purpose...
And i don't update TDB data with any triples, it remains constant.
And now i see:
> 1a. For a single (forward) Jena rule then you can always achieve the
> same with a SPARQL Update.
This, in this theory-clearness, is really new to me, thanks again, in my
backhead i have had it vice versa. So i can can give now the alternative
dev-scenerio:
A Jena-app with SPARQL Updates -> output RDF -> TDB/Fuseki -> A Query-UI
------------------------------------------------------------------------
It remaines developer-dependent, sometimes someone can formulate some
simple rules without making thoughts about harebrained SPARQL Updates...
Ok, i think this 2 dev-scenarios together can eventually be accepted to
give a try, hmm, as i understand Dave, or?
And now, in offline-prepairing of the tdbloader-input for better
enduser-queries, our 'secondary' problem, using Jena-Rules OR SPARQL
Update?
As a simple example to close this with a concrete thing:
@prefix skos: <http://www.w3.org/2004/02/skos/core#> .
[myrules5: (?x skos:subject ?y), (?y skos:broader ?z) -> (?x skos:subject
?z)]
What would you give as the equivalent SPARQL Update?
Thank you very much,
baran.
--
Using Opera's mail client: http://www.opera.com/mail/
Re: SPARQL vs Jena rules
Posted by tina sani <ti...@gmail.com>.
There is also something called SPIN (SPARQL Inferencing Notation). Can we
use it as the best possible alternative of Jena rules?
On Thu, Aug 31, 2017 at 10:48 AM, Dave Reynolds <da...@gmail.com>
wrote:
> On 30/08/17 15:10, baran.ha@gmail.com wrote:
>
> PS: I wonder why Dave doesn't comment in this thread. Perhaps because he
>> thinks, Lorenz is ok, i myself cannot stand the low-level-knowledge of the
>> users in this thread or no matter what you do, by some heavy data-input an
>> app with InfModel would hang anyway? Lorenz is ofcourse ok, but i 'guess'
>> Jena users are also very curious about Dave's comments...
>>
>
> I didn't comment on this thread because, as Andy has already pointed out,
> this seems to be a repeat of a recent similar thread (on which I did
> comment). That in turn was a near repeat of another similar thread. All
> from the same group.
>
> Also I think Lorenz has covered it all, with admirable patience.
>
> However, in an attempt to clarify the trade-offs in more depth maybe the
> following would be helpful:
>
> When comparing a rule system against a set of SPARQL Update queries there
> are several factors that affect the trade-offs including (1) the specific
> nature of the rules/queries, (2) the data flow and, (3) preferences on
> syntax and machinery.
>
> 1a. For a single (forward) Jena rule then you can always achieve the same
> with a SPARQL Update. For a single set of input data then SPARQL has the
> benefit of being a standard [1] and offering better performance over a
> store like TDB. Conversely SPARQL is much richer than Jena rules so there
> are things that you could achieve with a single SPARQL Update query using,
> say, property paths that would require multiple Jena rules.
>
> 1b. If you have a set of rules, but they don't create loops/recursion,
> then you can "stratify" them into groups of rules than can be run one after
> the other. In that case, for a single set of input data, then again you can
> implement it as a sequence of SPARQL Updates with similar benefits.
>
> 1c. If your rules can't be stratified, i.e. one rule can indirectly
> trigger itself, then it's more complex. In that case you would have to e.g.
> run the set of SPARQL Updates repeatedly until nothing new is deduced.
> Depending on the specifics of the rules and the data that may be quite
> expensive and you would be better off with something Jena rules. However,
> in some cases you may be able to use things like SPARQL property paths to
> achieve the desired effect without have to recurse.
>
> 2. If you have a single data set and just want to run your rules on it
> then the above applies. If you are repeatedly adding new data and want to
> keep your deductions up to date then the Jena forward rules engine has the
> advantage that it keeps all the partial matches around. So addition of one
> more triple may cause a rule to fire without it having to search for all
> the other triples in the body. This is also why "recursive" rules work
> relatively efficiently.
>
> This doesn't apply if you delete data. In that case Jena rules have to
> start over and can't reuse state across data deletions.
>
> If you keeping changing your data but very rarely ask questions of it, and
> then only limited questions, then Jena back rules have advantages. The
> backward engine will only run the rules needed for the specific query. If
> that's a lot fewer than the overall rules then that should be cheaper than
> running a full forward deduction using SPARQL Updates. In this situation it
> may be possible to achieve the same effects through SPARQL query (not
> update) by query rewriting but that's a whole different ball game.
>
> 3. With Jena rules you have some prebuilt machinery for running the rules
> (InfGraphs and all that) and some support for externalizing the rules in
> separate files. With SPARQL you have to create all that (though it's easy)
> and you have a nicer syntax.
>
> So fundamentally, like all "X vs Y" questions it depends on the specifics
> of what you are trying to do.
>
> Dave
>
> [1] There is a standard for rules, RIF, but it is not aimed at
> particularly RDF processing and post-dates Jena rules.
>
Re: SPARQL vs Jena rules
Posted by Dave Reynolds <da...@gmail.com>.
On 30/08/17 15:10, baran.ha@gmail.com wrote:
> PS: I wonder why Dave doesn't comment in this thread. Perhaps because he
> thinks, Lorenz is ok, i myself cannot stand the low-level-knowledge of
> the users in this thread or no matter what you do, by some heavy
> data-input an app with InfModel would hang anyway? Lorenz is ofcourse
> ok, but i 'guess' Jena users are also very curious about Dave's comments...
I didn't comment on this thread because, as Andy has already pointed
out, this seems to be a repeat of a recent similar thread (on which I
did comment). That in turn was a near repeat of another similar thread.
All from the same group.
Also I think Lorenz has covered it all, with admirable patience.
However, in an attempt to clarify the trade-offs in more depth maybe the
following would be helpful:
When comparing a rule system against a set of SPARQL Update queries
there are several factors that affect the trade-offs including (1) the
specific nature of the rules/queries, (2) the data flow and, (3)
preferences on syntax and machinery.
1a. For a single (forward) Jena rule then you can always achieve the
same with a SPARQL Update. For a single set of input data then SPARQL
has the benefit of being a standard [1] and offering better performance
over a store like TDB. Conversely SPARQL is much richer than Jena rules
so there are things that you could achieve with a single SPARQL Update
query using, say, property paths that would require multiple Jena rules.
1b. If you have a set of rules, but they don't create loops/recursion,
then you can "stratify" them into groups of rules than can be run one
after the other. In that case, for a single set of input data, then
again you can implement it as a sequence of SPARQL Updates with similar
benefits.
1c. If your rules can't be stratified, i.e. one rule can indirectly
trigger itself, then it's more complex. In that case you would have to
e.g. run the set of SPARQL Updates repeatedly until nothing new is
deduced. Depending on the specifics of the rules and the data that may
be quite expensive and you would be better off with something Jena
rules. However, in some cases you may be able to use things like SPARQL
property paths to achieve the desired effect without have to recurse.
2. If you have a single data set and just want to run your rules on it
then the above applies. If you are repeatedly adding new data and want
to keep your deductions up to date then the Jena forward rules engine
has the advantage that it keeps all the partial matches around. So
addition of one more triple may cause a rule to fire without it having
to search for all the other triples in the body. This is also why
"recursive" rules work relatively efficiently.
This doesn't apply if you delete data. In that case Jena rules have to
start over and can't reuse state across data deletions.
If you keeping changing your data but very rarely ask questions of it,
and then only limited questions, then Jena back rules have advantages.
The backward engine will only run the rules needed for the specific
query. If that's a lot fewer than the overall rules then that should be
cheaper than running a full forward deduction using SPARQL Updates. In
this situation it may be possible to achieve the same effects through
SPARQL query (not update) by query rewriting but that's a whole
different ball game.
3. With Jena rules you have some prebuilt machinery for running the
rules (InfGraphs and all that) and some support for externalizing the
rules in separate files. With SPARQL you have to create all that (though
it's easy) and you have a nicer syntax.
So fundamentally, like all "X vs Y" questions it depends on the
specifics of what you are trying to do.
Dave
[1] There is a standard for rules, RIF, but it is not aimed at
particularly RDF processing and post-dates Jena rules.
Re: SPARQL vs Jena rules
Posted by ba...@gmail.com.
On Sun, 27 Aug 2017 11:54:36 +0200, Lorenz B.
<bu...@informatik.uni-leipzig.de> wrote:
> Hello Baran,
>
>
>
>
> Kind regards,
> Lorenz
>
>>
>> I think statements like
>>
>> On Fri, 25 Aug 2017 11:52:46 +0200, Lorenz Buehmann
>> <bu...@informatik.uni-leipzig.de> wrote:
>>
>>> .... Inferencing and querying are totally different
>>> things. So why are you thinking about refactoring the whole project?
>>
>> or in next posting
>>
>>> Again, why do you compare those two Jena mechanisms? What is the
>>> expected outcome?
>>
>> are generally spoken confining snd mistakable for Jena-users making
>> thoughts about a proper design.
>>
>> Assume i have following dev-scenario:
>>
>> A Jena-app with InfModel + Rules-List -> output RDF -> TDB/Fuseki -> A
>> Query-UI
>>
>> (Query UI contains a lot of queries which users activate with a mouse
>> click and get responses presented in the same UI.)
>>
>> Now you i can try to add rules to my rules-list so that i can
>> formulate some of the queries of my Query-UI in a more leightweight
>> way with better performance.
>>
>> (Or vice versa i change some of my queries so that i can delete some
>> rules of my rules-list which is not so interesting.)
> The question here was to compare rules vs. SPARQL CONSTRUCT queries to
> modify an existing dataset. Indeed, the combination of both might be
> more powerful, although it remains open what part of the semantics to
> cover by which mechanism.
> Nevertheless, it's totally use case dependent - what kind of rules, how
> many rules, size of the dataset, is the data volatile (forward chaining
> vs. backward chaining), what kind of queries, and so on and so forth.
>
> Good luck with the project.
Last not least, i would still like to add to this:
Experimenting with CONSTRUCT-queries can be in fact a relative direct help
if you are struggling with Jena-rules + SPARQL relations in a 'teased'
tripples-level although you perhaps never use CONSTRUCT-queries in the
product-level of your app.
Thanks to tina sani starting this thread-title 'SPRQL vs Jena rules'. This
stuff hasn't been enough handled in this listing as it deserves. And i am
also to blame for this because i didn't have had the aggressiv energy and
courage to put the right postings though i have had a lot of problems and
some very encouring app cases. What a pity when i look back.
thanks, baran
PS: I wonder why Dave doesn't comment in this thread. Perhaps because he
thinks, Lorenz is ok, i myself cannot stand the low-level-knowledge of the
users in this thread or no matter what you do, by some heavy data-input an
app with InfModel would hang anyway? Lorenz is ofcourse ok, but i 'guess'
Jena users are also very curious about Dave's comments...
*************
--
Using Opera's mail client: http://www.opera.com/mail/
Re: SPARQL vs Jena rules
Posted by "Lorenz B." <bu...@informatik.uni-leipzig.de>.
Hello Baran,
Kind regards,
Lorenz
>
> I think statements like
>
> On Fri, 25 Aug 2017 11:52:46 +0200, Lorenz Buehmann
> <bu...@informatik.uni-leipzig.de> wrote:
>
>> .... Inferencing and querying are totally different
>> things. So why are you thinking about refactoring the whole project?
>
> or in next posting
>
>> Again, why do you compare those two Jena mechanisms? What is the
>> expected outcome?
>
> are generally spoken confining snd mistakable for Jena-users making
> thoughts about a proper design.
>
> Assume i have following dev-scenario:
>
> A Jena-app with InfModel + Rules-List -> output RDF -> TDB/Fuseki -> A
> Query-UI
>
> (Query UI contains a lot of queries which users activate with a mouse
> click and get responses presented in the same UI.)
>
> Now you i can try to add rules to my rules-list so that i can
> formulate some of the queries of my Query-UI in a more leightweight
> way with better performance.
>
> (Or vice versa i change some of my queries so that i can delete some
> rules of my rules-list which is not so interesting.)
The question here was to compare rules vs. SPARQL CONSTRUCT queries to
modify an existing dataset. Indeed, the combination of both might be
more powerful, although it remains open what part of the semantics to
cover by which mechanism.
Nevertheless, it's totally use case dependent - what kind of rules, how
many rules, size of the dataset, is the data volatile (forward chaining
vs. backward chaining), what kind of queries, and so on and so forth.
Good luck with the project.
> baran
>
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center
Re: SPARQL vs Jena rules
Posted by ba...@gmail.com.
I think statements like
On Fri, 25 Aug 2017 11:52:46 +0200, Lorenz Buehmann
<bu...@informatik.uni-leipzig.de> wrote:
> .... Inferencing and querying are totally different
> things. So why are you thinking about refactoring the whole project?
or in next posting
> Again, why do you compare those two Jena mechanisms? What is the
> expected outcome?
are generally spoken confining snd mistakable for Jena-users making
thoughts about a proper design.
Assume i have following dev-scenario:
A Jena-app with InfModel + Rules-List -> output RDF -> TDB/Fuseki -> A
Query-UI
(Query UI contains a lot of queries which users activate with a mouse
click and get responses presented in the same UI.)
Now you i can try to add rules to my rules-list so that i can formulate
some of the queries of my Query-UI in a more leightweight way with better
performance.
(Or vice versa i change some of my queries so that i can delete some rules
of my rules-list which is not so interesting.)
baran
--
Using Opera's mail client: http://www.opera.com/mail/
Re: SPARQL vs Jena rules
Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
You should try to talk to and collaborate with your team members, Javed
Khan and Sidrah Shah...
Next, you're comparing a query language with a rule engine - those are
obviously different things (although you can do some things also in
SPARQL that you can do with Jena rules.)
Regarding performance, there is no answer. Obviously in Jena both is
executed in Java probably using some shared Jena core functionalities.
Nevertheless, there is no need for comparison.
The question that comes up here in the mailing list - why are you still
asking those basic questions? What is the task of the project? I
remember that you used Jena rules all the time - now you're think about
using SPARQL? Why? Inferencing and querying are totally different
things. So why are you thinking about refactoring the whole project? How
much time do you need for this academic project? I mean, it sounds like
you're working on it for almost one year now? Is this really necessary
and useful to spend so much time on it?
Lorenz
On 24.08.2017 13:25, tina sani wrote:
> Andy, I need some points in which SPARQL query can be better than rules to
> get the desired result?
>
> Is it fast (in terms of time) than jena rules to be executed by the engine?
> Second, in terms of expressiveness, how SPARQL is better than the rules?
> One point I think is jena rules does not support dis-junction while SPARQL
> does (UNION). ,
>
> On Thu, Aug 24, 2017 at 2:07 PM, Andy Seaborne <an...@apache.org> wrote:
>
>> This has been asked before, most recently 2017-08-14.
>>
>> https://lists.apache.org/thread.html/ae4c1f5dfbacfb9bf4294a4
>> cf2967e0c7050c81b20f80e6c425a9aa8@%3Cusers.jena.apache.org%3E
>>
>> Please search the archives before asking questions.
>>
>> Andy
>>
>> On 24/08/17 08:50, tina sani wrote:
>>
>>> What are some of advantages of SPARQL over (Jena) rules? I know only that
>>> SPARQL is W3C recommendation and jena rules are not. Similarly, Jena rules
>>> are monotonic which does not add/remove any data just infer new knowledge.
>>> How SPARQL is more expressive than rules?
>>>
>>> If we get some inference using SPARQL, how it differs (better) than
>>> inference using rules.
>>>
>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source
>>> =link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
>>> Virus-free.
>>> www.avast.com
>>> <https://www.avast.com/sig-email?utm_medium=email&utm_source
>>> =link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
>>> <#m_-5991634784996563873_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>
>>>
Re: SPARQL vs Jena rules
Posted by tina sani <ti...@gmail.com>.
Andy, I need some points in which SPARQL query can be better than rules to
get the desired result?
Is it fast (in terms of time) than jena rules to be executed by the engine?
Second, in terms of expressiveness, how SPARQL is better than the rules?
One point I think is jena rules does not support dis-junction while SPARQL
does (UNION). ,
On Thu, Aug 24, 2017 at 2:07 PM, Andy Seaborne <an...@apache.org> wrote:
> This has been asked before, most recently 2017-08-14.
>
> https://lists.apache.org/thread.html/ae4c1f5dfbacfb9bf4294a4
> cf2967e0c7050c81b20f80e6c425a9aa8@%3Cusers.jena.apache.org%3E
>
> Please search the archives before asking questions.
>
> Andy
>
> On 24/08/17 08:50, tina sani wrote:
>
>> What are some of advantages of SPARQL over (Jena) rules? I know only that
>> SPARQL is W3C recommendation and jena rules are not. Similarly, Jena rules
>> are monotonic which does not add/remove any data just infer new knowledge.
>> How SPARQL is more expressive than rules?
>>
>> If we get some inference using SPARQL, how it differs (better) than
>> inference using rules.
>>
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source
>> =link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
>> Virus-free.
>> www.avast.com
>> <https://www.avast.com/sig-email?utm_medium=email&utm_source
>> =link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
>> <#m_-5991634784996563873_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>>
Re: SPARQL vs Jena rules
Posted by Andy Seaborne <an...@apache.org>.
This has been asked before, most recently 2017-08-14.
https://lists.apache.org/thread.html/ae4c1f5dfbacfb9bf4294a4cf2967e0c7050c81b20f80e6c425a9aa8@%3Cusers.jena.apache.org%3E
Please search the archives before asking questions.
Andy
On 24/08/17 08:50, tina sani wrote:
> What are some of advantages of SPARQL over (Jena) rules? I know only that
> SPARQL is W3C recommendation and jena rules are not. Similarly, Jena rules
> are monotonic which does not add/remove any data just infer new knowledge.
> How SPARQL is more expressive than rules?
>
> If we get some inference using SPARQL, how it differs (better) than
> inference using rules.
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
> Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> <#m_-5991634784996563873_DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>