Introduction to RDF & SPARQL - Joinup.eu

Training Module 1.3 OPEN DATA SUPPORT Introduction to RDF & SPARQL PwC firms help organisations and individuals create the value theyre looking for. Were a network of firms in 158 countries with close to 180,000 people who are committed to delivering quality in assurance, tax and advisory services. Tell us what matters to you and find out more by visiting us at www.pwc.com. PwC refers to the PwC network and/or one or more of its member firms, each of which is a separate legal entity. Please see www.pwc.com/structure for further details. This presentation has been created by PwC Presentation metadata Open Data Support is funded by the European Commission under SMART 2012/0107 Lot 2: Provision of services for the Publication, Access and Reuse of Open Public Data across the European Union,

through existing open data portals(Contract No. 30CE-0530965/00-17). 2014 European Commission Authors: Michiel De Keyzer, Nikolaos Loutas and Stijn Goedertier Disclaimers 1.The views expressed in this presentation are purely those of the authors and may not, in any circumstances, be interpreted as stating an official position of the European Commission. The European Commission does not guarantee the accuracy of the information included in this presentation, nor does it accept any responsibility for any use thereof. Reference herein to any specific products, specifications, process, or service by trade name, trademark, manufacturer, or otherwise, does not necessarily constitute or imply its endorsement, recommendation, or favouring by the European Commission. All care has been taken by the author to ensure that s/he has obtained, where necessary, permission to use any parts of manuscripts including illustrations, maps, and graphs, on which intellectual property rights already exist from the titular holder(s) of such rights or from her/his or their legal representative. 2.This presentation has been carefully compiled by PwC, but no representation is made or warranty given (either express or implied) as to the completeness or accuracy of the information it contains. PwC is not liable for the information in this presentation or any decision or consequence based on the use of it.. PwC will not be

liable for any damages arising from the use of the information contained in this presentation. The information contained in this presentation is of a general nature and is solely for guidance on matters of general interest. This presentation is not a substitute for professional advice on any particular matter. No reader should act on the basis of any matter contained in this publication without considering appropriate professional advice. Slide 2 OPEN DATASUPPORT Learning objectives By the end of this training module you should have an understanding of: The Resource Description Framework (RDF); How to write/read RDF; How you can describe your data with RDF; What SPARQL is; The different types of SPARQL queries; How to write a SPARQL query. OPEN DATASUPPORT Slide 3 Content This module contains ... An introduction to the Resource Description Framework

(RDF) for describing your data. - What is RDF? - How is it structured? - How to represent your data in RDF. An introduction to SPARQL on how you can query and manipulate data in RDF. Pointers to further reading, examples and exercises. Find more on: training.opendatasupport.eu OPEN DATASUPPORT Slide 4 Resource Description Framework An introduction on RDF. OPEN DATASUPPORT Slide 5 RDF in the stack of Semantic Web technologies RDF stands for: - Resource: Everything that can have a unique identifier (URI), e.g.

pages, places, people, dogs, products... - Description: attributes, features, and relations of the resources - Framework: model, languages and syntaxes for these descriptions RDF was published as a W3C recommendation in 1999. RDF was originally introduced as a data model for metadata. RDF was generalised to cover knowledge of all kinds. OPEN DATASUPPORT Slide 6 Where can I find the RDF Specification http://www.w3.org/RDF/ OPEN DATASUPPORT Slide 7 Example: RDF description of an organisation Publications Office, 2, rue Mercier, 2985 Luxembourg, LUXEMBOURG

> PUBL> Publications Publications Office< Office< /rdfs:label> /rdfs:label> rdf:resource=http://example.com/site/1234/>

rdf:about=http://example.com/site/1234/> 2, 2, rue rue Mercier, Mercier, 2985 2985 Luxembourg, Luxembourg, LUXEMBOURG LUXEMBOURG OPEN DATASUPPORT Slide 8 RDF structure Triples, graphs and syntax. OPEN DATASUPPORT Slide 9 What is a triple? RDF is a general syntax for representing data on the Web.

Every piece of information expressed in RDF is represented as a triple: Subject a resource, which may be identified with a URI. Predicate a URI-identified reused specification of the relationship. Object a resource oraliteral to which the subject is related. Example: name of dataset: http://publications.europa.eu/resource/authority/file-type/ has a title File types Name Authority List. Subject OPEN DATASUPPORT Predicat e Object Slide 10 RDF is graph based Graph =

A collection of triples Publications Publications Office Office has a name http://open-data.europa.eu/en/data/ http://open-data.europa.eu/en/data/ publisher/publ publisher/publ has a publisher http://publications.europa.eu/ http://publications.europa.eu/ resource/authority/file-type/ resource/authority/file-type/ has a title File File types types Name Name Authority Authority List List OPEN DATASUPPORT

Slide 11 RDF Syntax RDF/XML File types Name Authority List< /dct:title> Publications Office Description of data triples Subject Predicate RDF/XML is currently the only syntax that is standardised by W3C.

Object OPEN DATASUPPORT Slide 12 Graph xmlns:dcat=http://www.w3.org/TR/vocab-dcat/ xmlns:dct=http://purl.org/dc/terms/ Definition RDF Syntax Turtle of prefixes < http://publications.europa.eu/resource/authority/file-type/> a ; dct:title File types Name Authority List; dct:publisher . a ; Description dct:title Publications Office . Subject Predicate

Graph @prefix dcat: . Definition @prefix dct:

RDFa ... embedding RDF data in HTML ...

File types Name Authority List Publisher: Publications Office

Subject Predicate Object OPEN DATASUPPORT See See also: also: http://www.w3.org/TR/2012/NOTE-rdfa-primer-20120607/ http://www.w3.org/TR/2012/NOTE-rdfa-primer-20120607/ Slide 14

How to represent data in RDF Classes, properties and vocabularies OPEN DATASUPPORT Slide 15 RDF Vocabulary A vocabulary is a data model comprising classes, properties and relationships which can be used for describing your data and metadata. RDF Vocabularies are sets of terms used to describe things. A term is either a class or a property. Object type properties (relationships) Data type properties (attributes) OPEN DATASUPPORT Slide 16 What are classes, relationships and properties? Class. A construct that represents things in the real and/or information world, e.g. a person, an organisation, a concepts such as health or freedom.

Relationship. A link between two classes; for the link between a document and the organisation that published it (i.e. organisation publishes document), or the link between a map and the geographic region it depicts (i.e. map depicts geographic region). In RDF relationships are encoded as object type properties. Property. A characteristic of a class in a particular dimension such as the legal name of an organisation or the date and time that an observation was made. OPEN DATASUPPORT Slide 17 Class Examples of classes, relationships and properties Dataset a Property http://.../authority/ file-type/

title Agent Relationshi p publisher a http://.../publisher/ publ title File types Name Authority List OPEN DATASUPPORT Publications Office Slide 18 Reusing RDF vocabularies Reuse greatly aids interoperability of your data.

Use of dcterms:created, for example, the value for which should be a data typed date such as 2013-02-21^^xsd:date, is immediately processable by many machines. If your schema encourages data publishers to use a different term and date format, such as ex:date "21 February 2013" data published using your schema will require further processing to make it the same as everyone else's. Reuse adds credibility to your schema. It shows it has been published with care and professionalism, again, this promotes its reuse. Reuse is easier and cheaper. Reusing classes and properties from well defined and properly hosted vocabularies avoids your having to replicate that effort. See See also: also: https://joinup.ec.europa.eu/community/semic/document/cookbook-transl https://joinup.ec.europa.eu/community/semic/document/cookbook-transl ating-data-models-rdf-schemas ating-data-models-rdf-schemas http://www.slideshare.net/OpenDataSupport/model-your-data-metadata http://www.slideshare.net/OpenDataSupport/model-your-data-metadata OPEN DATASUPPORT Slide 19

Where can I find existing vocabularies? http://joinup.ec.europa.eu/ 11 Refine the search results via the Refine the search results via the faceted search filters. faceted search filters. 22 OPEN DATASUPPORT 33 Slide 20 See See also: also: http://www.w3.org/wiki/TaskForces/CommunityProj http://www.w3.org/wiki/TaskForces/CommunityProj ects/LinkingOpenData/CommonVocabularies ects/LinkingOpenData/CommonVocabularies

Well-known vocabularies DCAT-AP Vocabulary for describing datasets in Europe Core Person Vocabulary Vocabulary to describe the fundamental characteristics of a person, e.g. the name, the gender, the date of birth... DOAP Vocabulary for describing projects ADMS Vocabulary for describing interoperability assets. Dublin Core Defines general metadata attributes Registered Organisation Vocabulary Vocabulary for describing organizations, typically in a national or regional register

Organization Ontology for describing the structure of organizations Core Location Vocabulary Vocabulary capturing the fundamental characteristics of a location. Core Public Service Vocabulary Vocabulary capturing the fundamental characteristics of a service offered by public administration schema.org Agreed vocabularies for publishing structured data on the Web elaborated by Google, Yahoo and Microsoft OPEN DATASUPPORT Slide 21 Model your own vocabulary as an RDF Schema If there is no suitable authoritative reusable vocabulary for describing your data, use conventions for describing your

own vocabulary: - RDF Schema (RDFS) - Web Ontology Language (OWL) cpsv:PublicService aa rdfs:Class, Example: definition of a class owl:Class; : cpsv:PublicService rdfs:Class, owl:Class; rdfs:label rdfs:label "Public "Public Service"@en; Service"@en; rdfs:comment "This rdfs:comment "This class class represents represents the the service service itself. itself. As As noted noted in

in the scope, a public service is the capacity to carry out a the scope, a public service is the capacity to carry out a procedure and procedure and exists exists whether whether it it is is used used or or not. not. It It is is aa set

set of of deeds deeds and and acts acts performed performed by by or or on on behalf behalf of of aa public public agency agency for for the the benefit citizen, benefit of of aa citizen, aa business business or or another another public public agency."@en. agency."@en.

OPEN DATASUPPORT See See also: also: http://www.slideshare.net/OpenDataSupport/model-yourhttp://www.slideshare.net/OpenDataSupport/model-yourdata-metadata data-metadata Slide 22 Introduction to SPARQL The RDF Query Language OPEN DATASUPPORT Slide 23 About SPARQL SPARQL is the standard language to query graph data represented as RDF triples. SPARQL Protocol and RDF Query Language One of the three core standards of the Semantic Web, along with RDF and OWL. Became a W3C standard January 2008. SPARQL 1.1 is a W3C Recommendation since March 2013. OPEN DATASUPPORT

Slide 24 Types of SPARQL queries SELECT Return a table of all X, Y, etc. satisfying the following conditions ... CONSTRUCT Find all X, Y, etc. satisfying the following conditions ... and substitute them into the following template in order to generate (possibly new) RDF statements, creating a new graph. DESCRIBE Find all statements in the dataset that provide information about the following resource(s) ... (identified by name or description) ASK See See also: also: Are there any X, Y, etc. satisfyinghttp://www.euclid-project.eu/modules/chapter2 the following http://www.euclid-project.eu/modules/chapter2 conditions ... OPEN DATASUPPORT

Slide 25 Structure of a SPARQL Query PREFIX dct: http://purl.org/dc/terms/ PREFIX dcat: http://www.w3.org/TR/vocab-dcat/ Type of query SELECT ?title WHERE Variables, i.e. what to search for { ?x rdf:type dcat:Dataset . ?dataset rdf:title ?title RDF triple patterns, } i.e. the conditions that have to be met OPEN DATASUPPORT Definition of prefixes Slide 26

SELECT return the name of a dataset with particular URI Sample data rdf:type rdf:type dcat:Dataset. dcat:Dataset. dct:title File dct:title File types types Name Name Authority Authority List List .. dct:publisher dct:publisher < < http://open-data.europa.eu/en/data/publisher/publ>. http://open-data.europa.eu/en/data/publisher/publ>. < < http://.../publisher/publ> http://.../publisher/publ> rdf:type rdf:type <

http://.../publisher/publ> dct:title < http://.../publisher/publ> dct:title dct:Agent dct:Agent .. Publications Publications Office Office .. Query PREFIX PREFIX dcat: dcat: PREFIX PREFIX dct: dct: SELECT SELECT ?dataset ?dataset WHERE WHERE {{ org:hasRegisteredSite

org:hasRegisteredSite ?dataset ?dataset .. }} Result name File types Name Authority List OPEN DATASUPPORT Slide 27 SELECT - return the name and publisher of a dataset Sample data rdf:type rdf:type dcat:Dataset. dcat:Dataset. dct:title dct:title File File types types Name Name Authority Authority List List ..

dct:publisher dct:publisher < < http://open-data.europa.eu/en/data/publisher/publ>. http://open-data.europa.eu/en/data/publisher/publ>. < < http://.../publisher/publ> http://.../publisher/publ> rdf:type rdf:type < < http://.../publisher/publ> http://.../publisher/publ> dct:title dct:title Query dct:Agent dct:Agent .. Publications Publications Office Office .. PREFIX PREFIX dcat: dcat:

PREFIX dct: PREFIX dct: SELECT SELECT ?dataset ?dataset ?publisher ?publisher WHERE WHERE {http://.../authority/file-type/ {http://.../authority/file-type/ dct:publisher dct:publisher ?publisherURI. ?publisherURI. http://.../authority/file-type/ http://.../authority/file-type/ dct:title dct:title ?dataset. ?dataset. ?publisherURI ?publisherURI dct:title dct:title ?publisher ?publisher .. }} Result dataset pubisher

File types Name Authority List Dahliastraat 24, 2160 Wommelgem OPEN DATASUPPORT Slide 28 SPARQL Example EU ODP (1) OPEN DATASUPPORT Slide 29 SPARQL Example EU ODP (2) OPEN DATASUPPORT Slide 30 SPARQL Example EU ODP (2) OPEN DATASUPPORT Slide 31

SPARQL Update Can be used for... Adding data (INSERT) Deleting data (DELETE) Loading RDF Graph (LOAD / LOAD .. INTO) Clearing an RDF Graph (CLEAR GRAPH) Creating RDF Graphs (CREATE GRAPH) Removing RDF Graphs (DROP GRAPH) Copying RDF Graphs (COPY GRAPH ... TO GRAPH) Moving RDF Graphs (MOVE GRAPH ... TO GRAPH) Adding RDF Graphs (ADD GRAPH TO GRAPH) OPEN DATASUPPORT See See also: also: http://www.euclid-project.eu/modules/chapter2 http://www.euclid-project.eu/modules/chapter2 http://www.w3.org/TR/sparql11-update/ http://www.w3.org/TR/sparql11-update/ Slide 32 Summary RDF is a general way to express data intended for publishing on the Web.

RDF data is expressed in triples: subject, predicate, object. Different syntaxes exist for expressing data in RDF. SPARQL is a standardised language to query graph data expressed as RDF. SPARQL can be used to query and update RDF data. OPEN DATASUPPORT Slide 33 Group questions Go to the SPARQL end-point of the EU Open Data Portal and http://www.visualpharm.com (1) Query for all the publishers (2) Query for the number of datasets per publisher (3) Query for all the datasets of DG SANCO https://open-data.europa.eu/en/linked-data OPEN DATASUPPORT Slide 34 Thank you! ...and now YOUR questions?

OPEN DATASUPPORT Slide 35 References Semantic Web Stack. W3C. http://www.w3.org/DesignIssues/diagrams/sweb-stack/2006a.png Resource Description Framework. W3C. http://www.w3.org/RDF/ Linked Data Cookbook. W3C. http://www.w3.org/2011/gld/wiki/Linked_Data_Cookbook Cookbook for translating data models to RDF schemas. ISA Programme. https://joinup.ec.europa.eu/community/semic/document/cookbook-tran slating-data-models-rdf-schemas Common Vocabularies / Ontologies / Micromodels. W3C.

http://www.w3.org/wiki/TaskForces/CommunityProjects/LinkingOpenD ata/CommonVocabularies SPARQL Query Language for RDF. W3C. http://www.w3.org/TR/rdf-sparql-query/ Module 2: Querying Linked Data. EUCLID. http://www.euclid-project.eu/modules/course2 OPEN DATASUPPORT Module 2: Querying Linked Data. EUCLID. http://www.euclid-project.eu/modules/course2 SPARQL 1.1 Update. W3C.. http://www.w3.org/TR/sparql11-update/ Slide 36 Further reading Learning SPARQL. Bob DuCharme. http://www.learningsparql.com/

Semantic Web for the working ontologist. Dean Allemang, Jim Hendler. http://workingontologist.org/ EUCLID - Course 2: Querying Linked Data http://www.euclid-project.eu/modules/course2 OPEN DATASUPPORT Slide 37 Related projects and initiatives Joinup, https://joinup.ec.europa.eu/ Linked Open Vocabularies, http://okfn.org/ W3C GLD WG, http://www.w3.org/2011/gld/wiki/Main_Page W3C Schools Learn RDF http://www.w3schools.com/rdf/default.asp EUCLID, http://euclid-project.eu/ TopBraid Composer Protg Ontology Editor , http://protege.stanford.edu/ XML Summer School http://xmlsummerschool.com/ OPEN DATASUPPORT Slide 38 Be part of our team...

Find us on Join us on Open Data Support http://www.slideshare.net/OpenDataSupport Open Data Support http://goo.gl/y9ZZI Follow us @OpenDataSupport OPEN DATASUPPORT http://www.opendatasupport.eu Contact us [email protected] Slide 39

Recently Viewed Presentations

  • The Memory Hierarchy Cache, Main Memory, and Virtual Memory ...

    The Memory Hierarchy Cache, Main Memory, and Virtual Memory ...

    The cache memory is always smaller than the main memory (else why have a cache?). For this reason, it is often the case that a memory block being placed into the cache must replace a memory block already there. The...
  • Standards of Professional Performance for Registered ...

    Standards of Professional Performance for Registered ...

    Standards of Professional Performance for Registered Dietitians in Education of Dietetics Practitioners DEP AREA MEETINGS 2008 Provides quality education and service based on client expectations and needs.
  • Cells - monroe.k12.ky.us

    Cells - monroe.k12.ky.us

    This pigment is present in the chloroplasts. Absent. As animals lack this pigment, they cannot make their own food. Cell Division Cell division takes place by the formation of cell plate in the center of the dividing cell. This becomes...
  • PowerPoint Presentation

    PowerPoint Presentation

    England Takes Interest in the New World. By the 1580s, England's Queen Elizabeth I (pictured left) sought to plant colonies in the New World to challenge the might of her enemy, Spain. England's victory over the . Spanish Armada in...
  • RECONSTRUCTION

    RECONSTRUCTION

    Pastoral scene of the gallant southThe bulging eyes and the twisted mouthScent of magnolias, sweet and freshThen the sudden smell of burning flesh. Here is fruit for the crows to pluckFor the rain to gather, for the wind to suckFor...
  • Native Sports Team Names - Mr. Soulis

    Native Sports Team Names - Mr. Soulis

    A Lakota (Sioux) peace pipe stem, without the pipe bowl, displayed at the United States Library of Congress. West Coast Art: On the West Coast, Native people were more settled because of an abundance of food all year round. ......
  • Chapter 17 -- Capital Structure Determination

    Chapter 17 -- Capital Structure Determination

    Costs are borne by shareholders (Jensen & Meckling). Monitoring costs, like bankruptcy costs, tend to rise at an increasing rate with financial leverage. Agency Costs -- Costs associated with monitoring management to ensure that it behaves in ways consistent with...
  • What is Dystopian Literature? - Mrs.Kowalke

    What is Dystopian Literature? - Mrs.Kowalke

    What is Dystopian Literature? Utopian v. Dystopian Literature What does the word utopia mean? In as a literary genre, utopian literature refers to a detailed description of a nation or commonwealth ordered according to a system which the author proposes...