Semweb4j/filesQueries
From semanticweb.org
Up | Previous lesson | Next lesson | Next step
Contents |
[edit] Lesson 2: Serializing & Querying RDF Models
[edit] Recommendation: Download the code
It's highly recommended to download the tutorial code from Semweb4j. These pages may not always contain the latest changes of the API or the latest bugfixes in the tutorial code. Additional, the tutorial code contains small, runnable examples for each step of each lesson, so you don't have to copy-and-paste code from the tutorial web pages.
You can get the latest tutorial code via subversion (password:anonymous) at:
svn+ssh://anonymous@ontoware.org/svnroot/semweb4j/trunk/org/semweb4j/tutorial
For more information about the Subversion repository, see the semweb4j pages at ontoware.
The code should also be included in the directly downloadable semweb4j package but I haven't tested how this works yet :-)
[edit] Questions & Answers
- What is serialization?
- What about the different serialization syntaxes?
- RDF/XML
- a XML container format for RDF statements.
- see also: RDF/XML specification from W3C
- Notation3 (N3)
- A Notation3 statement looks like: <subjectURI> <predicateURI> <objectURI>
- remember: Notation 3 is more expressive than RDF, it's not only a RDF serialization.
- See Turtle below for more information
- see also: N3 specification from W3C
- Turtle
- a subset of Notation3
- "N3 is not an RDF syntax. A subset of N3, called 'turtle' is." (quote Max Völkel, Semweb4j developer)
- see also: Turtle specification
- TriG
- not implemented (21.02.07)
- TriX
- isn't implemented in Jena 2.4
- see also: TriX on hp.com
- RDF/XML
- What is querying?
- Querying a RDF model means defining a pattern for statements and getting a set of all statements to which this pattern can be applied. In natural language, this could be "every person somehow related to http://www.google.com" or "PersonA some-relation something" (which would return all statements with PersonA as subject). More formalized, the last example could be: "SELECT ?object WHERE {<http://www.example.com/PersonA> ?x ?object}" and we could query the selected object in detail.
- Which query languages for RDF exist?
- SPARQL, RDQL, TriQL
- You can use at least full SPARQL in RDF2Go, other depend on underlying triple store.
- SPARQL, RDQL, TriQL
- What is finding?
- Finding is querying without a query language like SPARQL but with simple patterns like (subject this, predicate that, object any). Finding is often faster than SPARQL querying, although some triple store may map finding to sparql-querying or some sparql-querys to finding patterns.
- It's recommended to use finding if possible and SPARQL (only) when you need more complex queries.
- What is SPARQL?
- SPARQL means SPARQL Protocol And RDF Query Language
- It is a query language for RDF graphs, so you can get (modified) subsets of a set of statements via patterns.
- Because SPARQL has many features, it won't be explained here in detail.
- If you don't know SPARQL yet, read the SPARQL specification from W3C before writing more complex SPARQL-queries. This can save you a lot of time.
- To understand this tutorial, you won't need any SPARQL knowledge.
- What are the main query types in SPARQL?
- SELECT * WHERE {?s ?p ?o} returns all results directly.
- CONSTRUCT {?s ?p "example"} WHERE {?s ?p ?o} returns all results but with "example" as object instead.
- DESCRIBE <http://www.example.com/test> returns all statements about the resource identified with "http://www.example.com/test".
- ASK {?s ?p "example"} returns True if "example" is an object in any statement.
[edit] Parts of this lesson
- Step 1: Simple serialization
- Step 2: Serialization syntaxes
- Step 3: Finding statements
- Step 4: SPARQL SELECT
- Step 5: SPARQL CONSTRUCT
- Step 6: SPARQL DESCRIBE
- Step 7: SPARQL ASK
- Step 8: A sample application