Hi everyone, As far as I have understood, SWRL rules are same as stored procedures in SQL. I have made few rules, but don't know how to utilize them in my application through query. I don't know whether I am thinking in the right way the SWRL rules are meant for, or not. Please show me the correct way of using them. Regards, Tariq
I'm not clear on "SWRL rules in SPARQL Query", but both SWRL and SPARQL are used to write rules for RDF and OWL-based ontologies. SPARQL is to OWL what SQL is to relational stores, particularly SPARQL 1.1. SWRL was a W3C submission, not a standard, that currently lives as the Basic Logic Dialect in RIF - I'd start with RIF BLD when looking for a standard way of expressing SWRL-styles rules.
In all cases - RDFS, OWL, RIF BLD, and SPARQL, the overall concept is to define a new set of facts based on existing facts - this is the basic mechanism of inference. In RDF those facts are defined in triples. RDFS defines basic subclass and subproperty triples, along with domain and range inferences. OWL defines a system of inferences based on First-Order Predicate Logic. RIF BLD is an exchange format for rules that defines Horn rules with "equality and a standard first-order semantics" (http://www.w3.org/TR/2010/REC-rif-bld-20100622/). Each of these are types of montonic logic - you can add facts but cannot retract facts.
SPARQL is a bit different, as it is query language for RDF. However, it can be used very effectively as a rule language that adds facts based on existing facts, with no restrictions on the types of inferences that can be computed. For example, is an easy translation to specify the OW2 RL profile in SPARQL. SWRL (RIF BLD) rules can also be easily translated into SPARQL. SPARQL 1.1 adds update statements, aggregates, projection, and other features that allows insertion, deletion, and modification of data (insert/delete) and data transformations.
The analog to stored procedures really isn't found in any of these technologies. What you need is some way to apply a series of queries and transformations to your data. In some ways, OWL does this, as a reasoner will apply OWL rules and add to an inferred graph (in most ontology editors). But it's hardcoded to do specific inferences, and can't delete data, etc. SPARQLMotion and other SPARQL technologies can take a series of queries and apply them in a specific order. That is probably closest you will get to stored procedures in these technologies.
SWRL is an extension to OWL (1) DL in a way that /looks like/ having rules in addition to traditional OWL DL ontologies/knowledgebases. The "rule" part of SWRL is in no way kind of procedural, but rather corresponds to purely logical implications. SWRL also does not provide closed world semantics, just in the case that you look for this. After all, SWRL, as OWL DL, corresponds to a syntactic fragment of standard first-order logic (which is inherently "open-world"), being just a larger fragment than OWL DL.