This content has been marked as final.
Show 4 replies
-
1. Re: Can we've custom rules that relate to instances & values rather than sc
alwu-Oracle Apr 25, 2008 9:02 PM (in response to bjg-Oracle)Your question is a bit fuzzy. Will the following rule satisfy your requirement?
?i rdf:type C
?i :P :x
==> ?i :Q :y
This rule appears to match your description of ANTICIDENT & Consequent.
However, it does not satisfy the query description. Not directly.
For the query you described, all you need is the following pattern in SDO_RDF_MATCH
'(?i rdf:type :C)(?i :Q :y)'
Apparently the above query will return instances of C that have value y for Q.
It also will return instances of C that have value x for P due to inference. -
2. Re: Can we've custom rules that relate to instances & values rather than sc
bjg-Oracle Apr 28, 2008 12:11 PM (in response to alwu-Oracle)Let me start with a more clear example (May be this would make the explanation clearer).
The purpose behind the rule (I want) is something like:
If I query for all instaces for ClassA that have the value of the property has_PropertyA as Open, then it should also give me all the instances that have a value for the property has_PropertyB as HIGH.
So, the rule I wrote was:
insert into mdsys.rdfr_RuleBase1 values
And, what I want when I query for the instances with PropertyA as Open (using the above rule), is
( 'Rule1' ,
'( ?instance rdf:type :ClassA)
(?instance :has_PropertyB ?b) (?b :hasValue ?d)
(?instance :has_PropertyA ?a) (?a :hasValue ?c)',
'REGEXP_like(d, ''HIGH'')' ,
'(?instance :has_PropertyA ?a) (?a :hasValue "Open")' ,
sdo_rdf_aliases(...)
)
);(1) instances with propertyA=Open [This is as asked]
(means an effective propertyA=Open OR propertyB=HIGH)
PLUS
(2) instances with propertyB=HIGH [This is extra but related info that I need]
---------------------------------------------------------------------------------------------------------------
But when queried, it gives a list of triples, all of which has propertyA as Open. I think it is due to my rule, and the way Oracle 10g does the inference.
=======================================================
The way Oracle 10g handles this inference mechanism through Rules is:
Each rule has an IF part and THEN part. It finds all the triple patterns that match the IF pattern and then for each of these, it creates a new triple pattern with the values specified in the THEN part. This is done while creating the RulesIndex for each ‘RuleBase-Model’ Combination. So, it means that it pre computes all the inferred triples (creating them as explained above).
For Example:
Actually, in the model, the instance with Id say ID0098 has propertyB=HIGH and propertyA=NOTOPEN. [This is similar to the actual instance value in the persisted model].
But, as this pattern matches the IF part of the Rule, it simply creates a new pattern having an instance with Id ID0098, propertyB=HIGH and replacing propertyA value as ‘Open’ (as specified in the THEN part of the Rule).
Hence when we query for the instances with propertyA=‘Open’ using our custom rule base, it simply executes a SQl statement and retrieves all the ‘Open’ propertyA patterns from both the Actual Model and the Inferred (Pre-computed) triples.
Your inputs are welcome. Tell me if I am still unclear. (I had to hide the details/data due to confidentiality).
Thanks
Bhaskar -
3. Re: Can we've custom rules that relate to instances & values rather than sc
alwu-Oracle Apr 28, 2008 7:31 PM (in response to bjg-Oracle)Hmm, to return instances that has_PropertyA=Open plus has_PropertyB=HIGH, you can simply write two SDO_RDF_MATCH queries and union them together.
select instance from table(sdo_rdf_match('( ?instance rdf:type :ClassA)
(?instance :has_PropertyB ?b) (?b :hasValue ''HIGH'')' , ..... )
union all
select instance from table(sdo_rdf_match('(?instance rdf:type :ClassA)
'(?instance :has_PropertyA ?a) (?a :hasValue "Open")', ....) -
4. Re: Can we've custom rules that relate to instances & values rather than sc
alwu-Oracle Apr 28, 2008 7:37 PM (in response to alwu-Oracle)Continue from previous post.
If you truly want to use rules, you can use something like
'( ?instance rdf:type :ClassA)
(?instance :has_PropertyB ?b) (?b :hasValue "HIGH")'
==>
'(?instance :has_PropertyA :PropertyOpen) (:PropertyOpen :hasValue "Open")' ,
NOTE that :PropertyOpen is a URI, not a variable.
Then when you query using pattern '(?instance rdf:type :ClassA)(?instance :has_PropertyA ?a) (?a :hasValue "Open")' , you should be able to get both.