SPARQL query equivalence

流过昼夜 提交于 2019-12-11 18:21:33

问题


Under the following context:

// owl in terms of Java-like syntax
Class Person {}
Class GraduateStudent extends Person {reference takesCourse [*] : GraduateCourse}
Class Student intersect Person {reference takesCourse [*] : Course}
Class UndergradStudent extends Student {}

Class Course{}
Class GraduateCourse extends Course{}
Class CsCourse extends Course{}

may I ask how should I read the following query?

// Q1: 
SELECT ?x ?y WHERE 
{ 
  {
    { ?x a :UndergradStudent . 
      ?x :takesCourse ?y }
     UNION 
    { ?x a :GraduateStudent .
      ?x :takesCourse ?y } 
  } 
   ?y a :Course .
}

I think it means select undergraduate students take any Course and graduate students take any Course, what bothers me to confirm this is the following:

  • Is there suppose to be a dot before ?y a :Course, such that the UNION-patterns inside {...} can be viewed as a single pattern to match, or it does not matter?

  • Can I distribute ?y a :Course over UNION, i.e. turn Q1 into Q2.

:

// Q2: 
SELECT ?x ?y WHERE 
{ 
  {
    { ?x a :UndergradStudent . 
      ?x :takesCourse ?y .
      ?y a :Course }
     UNION 
    { ?x a :GraduateStudent .
      ?x :takesCourse ?y .
      ?y a :Course } 
    }
}

来源:https://stackoverflow.com/questions/49733756/sparql-query-equivalence

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!