Using SPARQL: predicate dumps/discovery etc

I understand the basic SPARQL grammar and form [Background: I want to 
migrate a factlog (http://www.the325project.org/factlog/325Factlog.xul) 
to remote, granular queries and away from monolithic RDF XML files]. As 
I migrate from my old XUL template queries to SPARQL, some questions 
popped up. I think they are of general interest. I hope so anyway.

1) predicates as variables and dumping/discovery:

Let's say running the following
	SELECT *
	WHERE {?person foaf:name ?name ; foaf:mbox ?mbox}

gets results like
[:p1 "joe" <mailto:joe@example.com>]
[:p2 "fred" <mailto:fred@example.com>]
etc

Consider:
	SELECT ?subject ?predicate WHERE { ?subject ?predicate ?object }

Do I get a dump of all of the predicates supported by each and every 
resource in a graph?

i.e. something like
[:p1 foaf:name]
[:p1 foaf:mbox]
[:p2 foaf:name]
[:p2 foaf:mbox]
etc?

If so, does the following retrieve all the values of all the 
predicates, in other words dump the graph?
	SELECT *
	WHERE { ?subject ?predicate ?object }

i.e. something like
[:p1 foaf:name "joe"]
[:p1 foaf:mbox <mailto:joe@example.com>]
etc

A variation of this, where you set the subject to :p1 would dump all of 
the values of its predicates ... true?

2) rdf:about value and value of "?subject"

# can I get the "rdf:about" from every resource
PREFIX rdf:    <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?about
WHERE { ?subject rdf:about ?about }

is this equivalent to (presuming all resources have abouts and aren't 
blank)?

SELECT ?subject

The subject variable is bound to an about uri value OR if blank, a 
unique id, scoped to the result. Is that right?

3) Types - just like any other predicate?

	SELECT *
	WHERE { ?subject rdf:type ?type }

will give me all of the types of all of the resources - right?

[:p1 foaf:Person]
[:p1 t3p:Gamekeeper] ... it's just an example!
i.e. all the values of type for resources.

4) objects become subjects: arcs in as well as arcs out are supported

Let's say "Event" resources reference "Person" resources using a 
predicate "t3p:involved". So will ...

SELECT ?person ?name ?eventName
WHERE
   { ?person foaf:name ?name .
     ?event t3p:involved ?person . <----- subject "person" becomes object
     ?event foaf:name ?eventName }

give me people names with the names of all of their events?

[:people/p1 "joe" "Joe goes to Cairo"]
[:people/p1 "joe" "Joe does Jordan"]
etc

Thx in advance for any misconceptions cleared up ...

Received on Friday, 6 May 2005 04:18:49 UTC