owl & sparql - snuids.snu.ac.kr/w/images/f/f0/wec_2009_owl_sparql.pdf · center for e-business...
TRANSCRIPT
OWL & SPARQL
2009. 12
Sang-goo Lee
School of Computer Science & Engineering
Center for E-Business Technology
Seoul National University, Seoul, Korea
Center for E-Business TechnologySeoul National University
Seoul, Korea
Copyright © 2008~2009 SNU Center for E-Business Technology. All rights reserved.
- 웹 정보 시스템 -
OWL & Description Logics
Copyright 2009 by CEBT
OWL
� Web Ontology Language (WOL? -> OWL)
� is built on top of RDF
� was designed to be interpreted by computers (not people)
� is a W3C Recommendation (standard)
� A richer ontology language
� relations between classes: e.g., disjointness
� cardinality: e.g., “exactly one”
� richer typing of properties
� characteristics of properties (e.g., symmetry)
� Three sublanguages
� OWL Lite - simplest
� OWL DL (includes OWL Lite) - constructs with restriction
� OWL Full (includes OWL DL) - full expressive power
OWL & SPARQL - 3Center for E-Business Technology
Copyright 2009 by CEBT
OWL
� Basic Structure (OWL Lite)
� (In)Equality: equivalentClass, equivalentProperty , sameAs , differentFrom , AllDifferent , distinctMembers ,
� Property Characteristics: ObjectProperty , DatatypeProperty , inverseOf , TransitiveProperty , SymmetricProperty , FunctionalProperty , InverseFunctionalProperty
� Property Restrictions: Restriction , onProperty , allValuesFrom , someValuesFrom ,
� Restricted Cardinality: minCardinality (only 0 or 1) , maxCardinality (only 0 or 1) , cardinality (only 0 or 1)
� Header Information: Ontology, imports
� Class Intersection: intersectionOf
� Versioning: versionInfo, priorVersion, backwardCompatibleWith, incompatibleWith, DeprecatedClass, DeprecatedProperty
� Annotation Properties: rdfs:label, rdfs:comment, rdfs:seeAlso, rdfs:isDefinedBy, AnnotationProperty, OntologyProperty
� Extended Structure (OWL DL & Full)
� Class Axioms: oneOf, dataRange, disjointWith, equivalentClass, rdfs:subClassOf
� Boolean Combinations of Class Expressions: unionOf, complementOf, intersectionOf
� Arbitrary Cardinality: minCardinality, maxCardinality, cardinality
� Filler Information: hasValue
OWL & SPARQL - 4Center for E-Business Technology
Copyright 2009 by CEBT
OWL Examples
<owl:Class rdf:about="#associateProfessor">
<owl:disjointWith rdf:resource="#professor"/>
<owl:disjointWith rdf:resource="#assistantProfessor"/>
</owl:Class>
<owl:Class rdf:ID="faculty">
<owl:equivalentClass rdf:resource="#academicStaffMember"/>
</owl:Class>
<owl:ObjectProperty rdf:ID="isTaughtBy">
<owl:domain rdf:resource="#course"/>
<owl:range rdf:resource= "#academicStaffMember"/>
<rdfs:subPropertyOf rdf:resource="#involves"/>
</owl:ObjectProperty>
OWL & SPARQL - 5Center for E-Business Technology
Copyright 2009 by CEBT
OWL Examples (cont.)
<owl:ObjectProperty rdf:ID="teaches">
<rdfs:range rdf:resource="#course"/>
<rdfs:domain rdf:resource= "#academicStaffMember"/>
<owl:inverseOf rdf:resource="#isTaughtBy"/>
</owl:ObjectProperty>
<owl:Class rdf:about="#firstYearCourse">
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="#isTaughtBy"/>
<owl:allValuesFrom rdf:resource="#Professor"/>
</owl:Restriction>
</rdfs:subClassOf>
</owl:Class>
OWL & SPARQL - 6Center for E-Business Technology
Copyright 2009 by CEBT
Description Logics?
� A family of logic based Knowledge Representation formalisms
� Descendants of semantic networks and KL-ONE
� Describe domain in terms of concepts (classes), roles (relationships)
and individuals
� Distinguished by:
� Formal semantics (typically model theoretic)
– Decidable fragments of FOL
� Provision of inference services
– Sound and complete decision procedures for key problems
OWL & SPARQL - 7Center for E-Business Technology
Copyright 2009 by CEBT
DL Basics
� Concepts (unary predicates/formulae with one free variable)
� E.g., Person, Father, Mother
� Roles (binary predicates/formulae with two free variables)
� E.g., hasChild, hasHudband
� Individual names (constants)
� E.g., Alice, Bob, Cindy
� Subsumption (relations between concepts)
� E.g. Female ⊆ Person
� Operators (for forming concepts and roles)
� And(Π) , Or(U), Not (¬)
� Universal qualifier (∀), Existent qualifier(∃)
� Number restriction : ≤, ≥, = � Inverse role (-), transitive role (+), Role hierarchy
OWL & SPARQL - 8Center for E-Business Technology
Copyright 2009 by CEBT
Example
OWL & SPARQL - 9Center for E-Business Technology
Copyright 2009 by CEBT
Role example
� (Inverse Role) hasParent = hasChild-
� hasParent(Bob,Alice) -> hasChild(Alice, Bob)
� (Transitive Role) ancestor+
� ancestor(Bob,David), ancestor(David, Mack) ->
ancestor(Bob,Mack)
� (Role Hierarchy) hasMother ⊆ hasParent
� hasMother(Bob,Alice) -> hasParent(Bob, Alice)
� HappyFather ⊆ Father Π ≥1 hasChild.Woman Π ≥1 hasChild.Man
OWL & SPARQL - 10Center for E-Business Technology
Copyright 2009 by CEBT
OWL as DL: Axioms
[Ian Horrocks]
OWL & SPARQL - 11Center for E-Business Technology
Copyright 2009 by CEBT
OWL as DL: Class Constructors
[Ian Horrocks]
OWL & SPARQL - 12Center for E-Business Technology
Copyright 2009 by CEBT
Knowledge Base
Tbox (schema)
Abox (data)
HappyFather ⊆ Person Π ≥1 hasChild.Woman Π ≥1 hasChild.Man
Happy-Father(Bob)
Inference System
Interface
[Ian Horrocks]
DL Knowledge Base
� Tbox (terminology, taxonomy): a set of axioms describing structure of domain (i.e., a conceptual schema)
� ABox (membership assertions): a set of axioms describing a concrete situation (data), e.g.: John:HappyFather; <John,Mary>:hasChild
� Separation has no logical significance
� But may be conceptually and implementationally convenient
OWL & SPARQL - 13Center for E-Business Technology
Copyright 2009 by CEBT
DL Knowledge Base Example
� Tbox (terminology, taxonomy)
� Abox (membership assertions)
OWL & SPARQL - 14Center for E-Business Technology
Copyright 2009 by CEBT
Description Logic Family
� DLs are a family of logic based KR formalisms
� Particular languages mainly characterised by:
� Set of constructors for building complex concepts and roles from simpler ones
� Set of axioms for asserting facts about concepts, roles and individuals
� ALC (Attributive Language with Complements) is the smallest DL
� ALC ::= ⊥ | A | ¬C | C ∧ D | C ∨ D | ∃R.C | ∀R.C
� Constructors include booleans (and, or, not), and
� Restrictions on role successors
OWL & SPARQL - 15Center for E-Business Technology
Copyright 2009 by CEBT
OWL Full, DL, Lite
� SHOIQ = OWL DL
� S =ALCR+: ALC with transitive role
� H = role hierarchy
� O = nominal, e.g, WeekEnd = {Saturday, Sunday}
� I = Inverse role
� Q = qualified number restriction e.g. ≥1 hasChild.Man
– N = number restriction e.g. ≥1 hasChild
� OWL Lite = SHIF(Dn)
� F = functionality: (≤1 R)
� Complexity
� SHOIQ: NExpTime (adding transitive roles => undecidable: OWL full)
� SHIF: ExpTime
OWL & SPARQL - 16Center for E-Business Technology
Triple store & SPARQL
Copyright 2009 by CEBT
createTripleStore(“seminar.db" )
addTriple (Person1 first-name Steve)
addTriple (Person1 isa Organizer)
addTriple (Person1 age 52)
addTriple (Person2 first-name Jans)
addTriple (Person2 isa Psychologist)
addTriple (Person2 age 50)
addTriple (Person3 first-name Craig)
addTriple (Person3 isa SalesPerson)
addTriple (Person3 age 32)
addTriple (Person1 colleague-of Person2)
addTriple (Person1 colleague-of Person3)
addTriple (Person1 likes Pizza)
addTriple ( Person3 neighbour-of Person1)
addTriple ( Person3 neighbour-of Person2)
Triples as Graph
[Franz, Inc., 2008]
OWL & SPARQL - 18Center for E-Business Technology
Copyright 2009 by CEBT
(select (?xname ?yname)
(?x colleague-of ?y)
(?y neighbour-of ?x)
(?x first-name ?xname)
(?y first-name ?yname))
Query the Graph
[Franz, Inc., 2008]
OWL & SPARQL - 19Center for E-Business Technology
Copyright 2009 by CEBT
Triple Store
� A system to provide a mechanism for persistent storage and
access of RDF graphs.
� Persistent RDF storage
� Why?
� Relational model vs OO model vs RDF model
� Everything is modeled as triples => very flexible
– cf. relational model
� Simple
– cf. relational model, OO model
� Standards –based
– cf. OO model
OWL & SPARQL - 20Center for E-Business Technology
Copyright 2009 by CEBT
Triple Store Architectures
� In memory
� Internal data representation of graph
� Will not scale
� RDB based
� Built on top of a relational DB - easy implementation
� Not optimized for RDF graph
� RDF specific
� Specially designed storage system for RDF graphs
� Optimized but New (not mature)
� AllegroGraph, Sesame, Oracle 11g (?)
� Issues
� Scalability
� Language support: SPARQL
� Level of inference: RDFS, OWL (levels), …
� Interoperability: APIs
� Relational-to-RDF mapping
OWL & SPARQL - 21Center for E-Business Technology
Copyright 2009 by CEBT
Triple Store Benchmarks
� Lehigh University Benchmark (LUBM)
� Ontology: The benchmark ontology (named Univ-Bench)
� Data Generator(UBA): Tool to generate synthetic OWL data over the Univ-Bench ontology in the unit of a university
� Test Queries: 14 test queries
� Tester (UBT) : The test module
� Ontology Benchmark (UOBM)
� extends the LUBM benchmark in terms of inference and scalability testing
� UOBM ontology and data set
� Berlin SPARQL Benchmark (BSBM)
� designed along an e-commerce use case
� SPARQL and SQL version available
� SP2Bench
� a scalable RDF data generator
� a set of benchmark queries
OWL & SPARQL - 22Center for E-Business Technology
Copyright 2009 by CEBT
SPARQL
� SPARQL is a query language and a protocol for accessing RDF
� designed by the W3C RDF Data Access Working Group.
� a W3C Recommendation: SPARQL Query Language for RDF,
http://www.w3.org/TR/rdf-sparql-query/
� SPARQL Query language can be used to get information from
RDF graphs.
� It provides facilities to:
� extract information in the form of URIs, blank nodes, plain and
typed literals.
� extract RDF subgraphs.
� construct new RDF graphs based on information in the queried
graphs.
OWL & SPARQL - 23Center for E-Business Technology
Copyright 2009 by CEBT
The Semantic Web Layer Tower
OWL & SPARQL - 24Center for E-Business Technology
Copyright 2009 by CEBT
Basic Graph Pattern
� Triple Patterns
� Matching a triple pattern to a graph: bindings between variables
and RDF Terms
?book dc:title ?title
x v
rdf:type rdf:Property
rdf:type rdf:type rdf:Property
SELECT ?x ?v WHERE { ?x ?x ?v }
Data
Query
Query Result
OWL & SPARQL - 25Center for E-Business Technology
Copyright 2009 by CEBT
Basic Graph Pattern - Multiple Matches
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?mbox
WHERE { ?x foaf:name ?name .
?x foaf:mbox ?mbox }
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
_:a foaf:name "Johnny Lee" .
_:a foaf:mbox <mailto:[email protected]> .
_:b foaf:name "Peter Guy" .
_:b foaf:mbox <mailto:[email protected]> .
name mbox
"Johnny Lee " <mailto:[email protected]>
"Peter Guy" <mailto:[email protected]>
Data
Query
Query Result
[ Written in Turtle format:Terse RDF Triple Language ]
OWL & SPARQL - 26Center for E-Business Technology
Copyright 2009 by CEBT
Value Constraints
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix : <http://example.org/book/> .
@prefix ns: <http://example.org/ns#> .
:book1 dc:title "SPARQL Tutorial" .
:book1 ns:price 42 .
:book2 dc:title "The Semantic Web" .
:book2 ns:price 23 .
title price
"The Semantic Web" 23
Data
Query
Query Result
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX ns: <http://example.org/ns#>
SELECT ?title ?price
WHERE { ?x ns:price ?price .
FILTER ?price < 30 .
?x dc:title ?title . }
OWL & SPARQL - 27Center for E-Business Technology
Copyright 2009 by CEBT
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix : <http://example.org/book/> .
@prefix ns: <http://example.org/ns#> .
:book1 dc:title "SPARQL Tutorial" .
:book1 ns:price 42 .
:book2 dc:title "The Semantic Web" .
:book2 ns:price 23 .
Optional graph patterns
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX ns: <http://example.org/ns#>
SELECT ?title ?price
WHERE { ?x dc:title ?title .
OPTIONAL { ?x ns:price ?price .
FILTER ?price < 30 }}title price
“SPARQL Tutorial“
"The Semantic Web" 23
Data
Query
Query Result
OWL & SPARQL - 28Center for E-Business Technology
Copyright 2009 by CEBT
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name
WHERE { ?x foaf:name ?name }
ORDER BY ?name
Order By
PREFIX : http://example.org/ns#
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
SELECT ?name
WHERE { ?x foaf:name ?name ; :empId ?emp }
ORDER BY DESC(?emp)
OWL & SPARQL - 29Center for E-Business Technology
Copyright 2009 by CEBT
nameX nameY nickY
"Alice" "Bob"
"Alice" "Clare" "CT"
In XML Form
<?xml version="1.0"?>
<sparql
xmlns="http://www.w3.org/2005/sparql-
results#">
<head>
<variable name="nameX"/>
<variable name="nameY"/>
<variable name="nickY"/>
</head>
<results>
<result>
<binding name="nameX">
<literal>Alice</literal>
</binding>
[SPARQL Variable Binding Results XML Format]
<binding name="nameY">
<literal>Bob</literal>
</binding>
</result>
<result>
<binding name="nameX">
<literal>Alice</literal>
</binding>
<binding name="nameY">
<literal>Clare</literal>
</binding>
<binding name="nickY">
<literal>CT</literal>
</binding>
</result>
</results>
</sparql>
OWL & SPARQL - 30Center for E-Business Technology
Copyright 2009 by CEBT
Query forms and Extensions
� Query forms
� SELECT: returns all, or a subset of the variables bound in a query pattern match
� CONSTRUCT: returns an RDF graph constructed by substituting variables in a set of triple templates
� DESCRIBE: returns an RDF graph that describes the resources found.
� ASK: returns whether a query pattern matches or not.
� Related specifications
� SPARQL Query Language for RDF
– http://www.w3.org/TR/rdf-sparql-query/
– defines the syntax and semantics of the SPARQL query language for RDF
� SPARQL Protocol for RDF
– http://www.w3.org/TR/rdf-sparql-protocol/
– defines the remote protocol for issuing SPARQL queries and receiving the results
� SPARQL Query Results XML Format
– http://www.w3.org/TR/rdf-sparql-XMLres/
– defines an XML document format for representing the results of SPARQL queries
OWL & SPARQL - 31Center for E-Business Technology
OWL & SPARQL
Center for E-Business TechnologySeoul National University
Seoul, Korea
Copyright © 2008~2009 SNU Center for E-Business Technology. All rights reserved.