Different query results when using named graphs

3 views
Skip to first unread message

Amin Tajgardoon

unread,
Sep 11, 2014, 10:21:42 AM9/11/14
to sta...@clarkparsia.com
Hi,

Based on this post on Stackoverflow I am trying to get depth of sub-classes in the class hierarchy, with the following query:

SELECT DISTINCT ?topLevel ?subClass ?directParent  (count(?mid) as ?depth)
FROM <tag:stardog:api:context:all>
WHERE{
  #get the top level classes
  ?topLevel rdf:type owl:Class .
 
  #get ?subClasses of ?topLevel classes
  ?mid rdfs:subClassOf* ?topLevel .
  ?subClass rdfs:subClassOf+ ?mid .
 
  #get the ?directParent of each subClass
  ?subClass rdfs:subClassOf ?directParent .
 
    }
GROUP BY ?topLevel ?subClass ?directParent
ORDER BY ?topLevel  ?depth

Although it completely works when all owl files are loaded  into the default graph, when I use 2 named graphs to split my classes, the same query returns wrong depths for sub-classes. Everything else in the results looks the same.
I tried Stardog 2.2.1 and 2.1.3.
I am wondering why the behavior is different when I use named graphs!
Please help me, I really need to split the data among separate named graphs.
Thanks you.

Mike Grove

unread,
Sep 11, 2014, 11:42:19 AM9/11/14
to stardog
For what it's worth, the spec forbids [1] what you're trying to do: "A property path does not span multiple graphs in a dataset."

If you want to provide the data to go with your query, and how it's partitioned into named graphs, we can take a look.  Our implementation doesn't strictly follow 18.1.7, so in theory, it may work.  But you should know that what you're doing it's very portable.

Cheers,

Mike

 
Please help me, I really need to split the data among separate named graphs.
Thanks you.

--
-- --
You received this message because you are subscribed to the C&P "Stardog" group.
To post to this group, send email to sta...@clarkparsia.com
To unsubscribe from this group, send email to
stardog+u...@clarkparsia.com
For more options, visit this group at
http://groups.google.com/a/clarkparsia.com/group/stardog?hl=en

Amin Tajgardoon

unread,
Sep 11, 2014, 7:21:38 PM9/11/14
to sta...@clarkparsia.com
Alright. I created the same tree in the stackoverflow post as two separate files, each containing a portion of the tree, using rdfs:subClassOf relationship. I ran the following query which is basically the same as in my last post, against two instances of Stardog 2.1.3 database; in one I loaded both owl files in the default context, in the other one, files were loaded into two separate named graphs (contexts). Here is how I did it via CLI:

>stardog data add --named-graph http://www.example.org/schema1 -- MYDB Desktop\Tree1.owl

>stardog data add --named-graph http://www.example.org/schema2 -- MYDB Desktop\Tree2.owl

Here is the query:

SELECT DISTINCT ?superLabel ?subLabel (count(?mid) as ?d)
FROM<tag:stardog:api:context:all>
WHERE{

  ?mid rdfs:subClassOf* ?super .
  ?sub   rdfs:subClassOf+ ?mid  .

  ?super rdfs:label ?superLabel .
  ?sub rdfs:label ?subLabel .
GROUP BY ?superLabel ?subLabel 
ORDER BY ?superLabel ?d

Here is the Result:

+------------+----------+-------+
| superLabel | subLabel |   d   |
+------------+----------+-------+
| "A"        | "B"      | 1     |
| "A"        | "C"      | 1     |
| "A"        | "D"      | 1     |
| "A"        | "E"      | 2     |
| "A"        | "F"      | 2     |
| "A"        | "G"      | 3     |
| "A"        | "H"      | 4     |
| "B"        | "F"      | 1     |
| "B"        | "E"      | 1     |
| "B"        | "G"      | 2     |
| "B"        | "H"      | 3     |
| "E"        | "G"      | 2     |
| "E"        | "H"      | 3     |
| "G"        | "H"      | 1     |
+------------+----------+-------+

Wrong results are highlighted above. Note that G and H are in schema2 context and others are in schema1.
I've attached the 2 files which I created in Protege.

Thank you for helping me.


To unsubscribe from this group and stop receiving emails from it, send an email to stardog+u...@clarkparsia.com.



--
Amin
Tree1.owl
Tree2.owl

Amin Tajgardoon

unread,
Sep 15, 2014, 9:27:38 AM9/15/14
to sta...@clarkparsia.com
Has anybody looked at my problem by any chance?
--
Amin
Reply all
Reply to author
Forward
0 new messages