Is there a way to query if ?p1 foaf:knows ?p2 in SPARQL for a graph that does not use the foaf:knows property, but instead uses the property :isParticipantIn ?

eg:

:Mike a foaf:Person . :Jane a foaf:Person . :Mike :isParticipantIn :ProjectBiosphere :Jane :isParticipantIn :ProjectBiosphere

So I want to use sparql CONSTRUCT and express that two people know each other if they participate in the same thing, to assert that:

:Mike :knows :Jane :Jane :knows :Mike

What would the SPARQL CONSTRUCT query look like? Should I instead define a new namedIndividual owl:Class, can there be restrictions on properties in OWL?

asked 23 Feb '13, 02:49

edan's gravatar image

edan
27326
accept rate: 0%


Q:What'd the query look like? A: (Omitting namespace prefixes)

CONSTRUCT {
 ?x foaf:knows ?y
}
WHERE {
?x :isParticipantIn ?z .
?y :isParticipantIn ?z .
FILTER (?x != ?y)
}

The query above will get two different people who work in the same project and create a foaf:knows relation between them.

permanent link

answered 23 Feb '13, 03:25

fadirra's gravatar image

fadirra
1.2k310
accept rate: 21%

Excellent, thank you! Have you used this technique before? Is there a place to find SPARQL patterns (not tutorials), similar to ontology design patterns website?

(23 Feb '13, 06:09) edan edan's gravatar image

AFAIK, I don't know if such thing (SPARQL querying patterns) exists on the Web. But that might be great if there's one :)

(23 Feb '13, 06:39) fadirra fadirra's gravatar image

With property paths and the comma notation, the pattern here can be written a bit more concisely as ?z ^:isParticipantIn ?x, ?y.

(23 May, 18:05) Joshua Taylor Joshua%20Taylor's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×1,301
×619
×91
×32

question asked: 23 Feb '13, 02:49

question was seen: 843 times

last updated: 23 May, 18:05