Dr. Alexandra I. Cristea - PowerPoint PPT Presentation

1 / 46
About This Presentation
Title:

Dr. Alexandra I. Cristea

Description:

CS 253: Topics in Database Systems: C4 Dr. Alexandra I. Cristea http://www.dcs.warwick.ac.uk/~acristea/ – PowerPoint PPT presentation

Number of Views:142
Avg rating:3.0/5.0
Slides: 47
Provided by: acristea
Category:

less

Transcript and Presenter's Notes

Title: Dr. Alexandra I. Cristea


1
CS 253 Topics in Database Systems C4
  • Dr. Alexandra I. Cristea
  • http//www.dcs.warwick.ac.uk/acristea/

2
  • Previously we looked at
  • XML, and its query language(s)
  • RDF
  • Next
  • RDF query languages

3
RDF query languages
4
Proposals
  • SPARQL
  • http//www.w3.org/TR/rdf-sparql-query/
  • RDQL
  • http//www.w3.org/Submission/RDQL/
  • RQL
  • http//139.91.183.309090/RDF/RQL/
  • SeRQL
  • http//www.openrdf.org/doc/sesame/users/ch06.html
  • Triple
  • http//triple.semanticweb.org/
  • N3
  • http//www.w3.org/DesignIssues/Notation3
  • Comparison of languages
  • http//www.aifb.uni-karlsruhe.de/WBS/pha/rdf-query
    /rdfquery.pdf

5
SeRQL
6
Introduction SeRQL
  • "Sesame RDF Query Language", pronounced "circle
  • new RDF/RDFS query language
  • currently being developed by Aduna as part of
    Sesame. http//www.openrdf.org/
  • It combines (best?) features of other (query)
    languages (RQL, RDQL, N-Triples, N3) and adds
    some of its own.

7
Sesame
  • open source RDF framework with support for RDF
    Schema inferencing and querying.
  • Originally, it was developed by Aduna (then known
    as Aidministrator) as a research prototype for
    the EU research project On-To-Knowledge.
  • further developed and maintained by Aduna in
    cooperation with NLnet Foundation, developers
    from Ontotext, and a number of volunteer
    developers

8
SeRQL's features
  • Graph transformation.
  • RDF Schema support.
  • XML Schema datatype support.
  • Expressive path expression syntax.
  • Optional path matching.

9
SeRQL basic building blocks
  • RDF
  • URIs,
  • literals and
  • variables URIs and literals
  • variables

10
Variables
  • identified by names.
  • must start with a letter or an underscore ('_')
  • and can be followed by zero or more letters,
    numbers, underscores, dashes ('-') or dots ('.').
  • Examples
  • Var1
  • _var2
  • unwise.var-name_isnt-it
  • SeRQL keywords are not allowed to be used as
    variable names.

11
(reserved) Keywords
  • Currently
  • select, construct, from, where, using,
    namespace, true, false, not, and, or, like,
    label, lang, datatype, null, isresource,
    isliteral, sort, in, union, intersect, minus,
    exists, forall, distinct, limit, offset.
  • case-insensitive, (unlike variable names).

12
URIs
  • full URIs
  • abbreviated URIs (QNames)

13
Full URIs
  • must be surrounded with "lt" and "gt".
  • Tend to be long (!!)
  • Examples
  • lthttp//www.openrdf.org/index.htmlgt
  • lthttp//www.w3.org/1999/02/22-rdf-syntax-nstypegt
  • ltmailtosesame_at_openrdf.orggt
  • ltfile///C\rdffiles\test.rdfgt

14
Abbreviated URIs (QNames)
  • Components
  • defined prefix (for the namespace) and a colon
    (),
  • then the URI part that is not a namespace
  • Examples
  • sesameindex.html
  • rdftype
  • foafPerson

15
Literals
  • Parts
  • label,
  • language tag, and
  • datatype
  • Examples
  • "foo"
  • "foo"_at_en
  • "ltfoo/gt"http//www.w3.org/1999/02/22-rdf-syntax-
    nsXMLLiteral
  • "ltfoo/gt"rdfXMLLiteral

Optional, mutually exclusive
16
Blank nodes
  • RDF has a notion of blank nodes.
  • nodes that are not labelled with a URI or
    literal.
  • Interpretation (?) "there exists a node such
    that..."
  • Blank nodes have internal identifiers
  • Shortcut in SeRQL
  • _bnode1
  • Attention problem of non-portability!!!

17
Path expressions
  • expressions that match specific paths through an
    RDF graph
  • usually, triples path expressions of length 1
  • in SeRQL arbitrary length

18
Basic path expressions
  • Query
  • persons who work for (companies that are) IT
    companies.

19
Original (possible) RDF
  • lt?xml version1.0?gt
  • ltrdfRDF xmlnsrdf"http//www.w3.org/1999/02/22-r
    df-syntax-ns" xmlnsfoo"http//www.mycompany.smt
    hg/company"gt
  • ltrdfDescription abouthttp//www.mycompany.smthg
    /company/Persongt
  • ltfooworksForgt rdfresourcehttp//www.mycompany.
    smthg/company/Company lt/fooworksForgt
  • lt/rdfDescriptiongt
  • ltrdfDescription abouthttp//www.mycompany.smthg
    /company/Companygt
  • ltrdftypegtrdfresourcehttp//www.mycompany.smth
    g/company/CompanySchemaITCompanylt/rdftypegt
  • lt/rdfDescriptiongt
  • lt/rdfRDFgt

20
Basic path expressions
  • Query
  • persons who work for (companies that are) IT
    companies.
  • Person fooworksFor Company rdftype
    fooITCompany

ltfooworksForgt
ltrdftypegt
Company
Person
ltfooITCompanygt
Triple (length 1)
21
Multiple Path Expressions
  • Separated with commas
  • Example
  • Person exworksFor Company,
  • Company rdftype exITCompany

22
Non-interesting nodes
  • Can be left empty
  • Examples
  • Person exworksFor rdftype exITCompany
  • Painting expainted_by exname "Picasso"

23
Path expression short cuts
  • Multi-value nodes
  • Branches
  • Reified statements

24
Multi-valued nodes
  • Multiple objects
  • subj1 pred1 obj1, obj2, obj3
  • Multiple subjects
  • subj1, subj2, subj3 pred1 obj1
  • Condition disjoint !!

25
Branches
  • subj1 pred1 obj1
  • pred2 obj2
  • Equivalent to
  • subj1 pred1 obj1,
  • subj1 pred2 obj2

26
Reified statements
  • reifSubj reifPred reifObj pred obj
  • Equivalent to
  • _Statement rdftype rdfStatement,
    _Statement rdfsubject reifSubj, _Statement
    rdfpredicate reifPred, _Statement rdfobject
    reifObj, _Statement pred obj

27
Optional Path Expressions
  • Person exname Name
  • exage Age
  • exemail EmailAddress

28
Queries in SeRQL
  • Select queries
  • returning a table of values, or a set of
    variable-value bindings.
  • SELECT, FROM, WHERE, LIMIT, OFFSET and USING
    NAMESPACE
  • Construct queries
  • returns a true RDF graph
  • CONSTRUCT, FROM, WHERE, LIMIT, OFFSET and USING
    NAMESPACE

29
Select queries
  • SELECT C FROM C rdftype rdfsClass
  • returns all URIs of classes
  • SELECT DISTINCT
  • FROM Country1 exborders exborders
    Country2
  • USING NAMESPACE ex lthttp//example.org/things
    gt

30
Construct queries
  • CONSTRUCT Parent exhasChild Child
  • FROM Child exhasParent Parent
  • USING NAMESPACE ex lthttp//example.org/things
    gt
  • CONSTRUCT
  • FROM SUB rdfssubClassOf SUPER
  • This query extracts all rdfssubClassOf relations
    from an RDF graph.

31
WHERE clause
  • Optional
  • Specifies Boolean constraints
  • SELECT Country
  • FROM Country expopulation Population
  • WHERE Population lt "1000000"xsdpositiveInteger
  • USING NAMESPACE ex lthttp//example.org/thingsgt

32
Nested WHERE clauses
  • Query 1 (normal WHERE-clause)
  • SELECT Name, EmailAddress
  • FROM Person foafname Name
  • exemail
    EmailAddress
  • WHERE EmailAddress LIKE "g"
  • Query 2 (nested WHERE-clause)
  • SELECT Name, EmailAddress
  • FROM Person foafname Name
  • exemail EmailAddress WHERE EmailAddress LIKE
    "g"
  • at most one nested WHERE-clause per optional path
    expression, and at most one 'normal' WHERE-clause

33
Results WHERE queries
  • Query 1
  • Name EmailAddress
  • Giancarlo giancarlo_at_example.work
  • Query 2 (nested WHERE)
  • Name EmailAddress
  • Michael 
  • Rubens 
  • Giancarlo "giancarlo_at_example.work"

34
LIKE operator
  • SELECT Country
  • FROM Country exname Name
  • WHERE Name LIKE netherlands" IGNORE CASE
  • USING NAMESPACE ex lthttp//example.org/thingsgt

35
Built-in predicates
  • X serqldirectSubClassOf Y
  • X serqldirectSubPropertyOf Y
  • X serqldirectType Y

36
Set combinatory operations
  • Union
  • Intersect
  • Minus

37
Union
  • SELECT title
  • FROM book dc10title title
  • UNION
  • SELECT title
  • FROM book dc11title title
  • USING NAMESPACE
  • dc10 lthttp//purl.org/dc/elements/1.0/gt,
    dc11 lthttp//purl.org/dc/elements/1.1/gt

38
Intersect
  • SELECT creator
  • FROM album dc10creator creator
  • INTERSECT
  • SELECT creator
  • FROM album dc11creator creator
  • USING NAMESPACE
  • dc10 lthttp//purl.org/dc/elements/1.0/gt,
  • dc11 lthttp//purl.org/dc/elements/1.1/gt

39
Minus (difference)
  • SELECT title
  • FROM album dc10title title
  • MINUS
  • SELECT title
  • FROM album dc10title title dc10creator
    creator
  • WHERE creator like "Paul"
  • USING NAMESPACE
  • dc10 lthttp//purl.org/dc/elements/1.0/gt,
  • dc11 lthttp//purl.org/dc/elements/1.1/gt

40
NULL values
  • SELECT
  • FROM X Y Z
  • WHERE isLiteral(Z) AND datatype(L) NULL
  • to check that a literal doesn't have a datatype

41
Query Nesting
  • IN
  • ANY, ALL
  • EXISTS

42
IN
  • SELECT name
  • FROM rdftype exPerson
  • exname name
  • WHERE name IN
  • ( SELECT n
  • FROM rdftype exAuthor
  • exname n )
  • USING NAMESPACE
  • ex http//example.org/things
  • retrieve all names of Persons, but only those
    names that also appear as names of Authors.

43
ANY, ALL
  • SELECT highestValue
  • FROM node exvalue highestValue
  • WHERE highestValue gt ALL
  • ( SELECT value
  • FROM exvalue value
  • )
  • USING NAMESPACE
  • ex lthttp//example.org/thingsgt

44
EXISTS
  • SELECT name, hobby
  • FROM rdftype exPerson
  • exname name
  • exhobby hobby
  • WHERE EXISTS
  • ( SELECT n
  • FROM rdftype exAuthor
  • exname n
  • exauthorOf
  • WHERE n name
  • )
  • USING NAMESPACE
  • ex lthttp//example.org/thingsgt

45
RDF Query Languages Conclusion
  • We have learned
  • There is a high competition for providing The RDF
    query language
  • No standards as yet
  • We have looked in more details at one of them,
    SeRQL, as it is an implementers language paired
    with an existing RDF repository tool, Sesame
  • Many features in SeRQL remind us of SQL, thus
    learning threshold should be low

46
  • Next
  • OWL
Write a Comment
User Comments (0)
About PowerShow.com