rdf for developers n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
RDF for Developers PowerPoint Presentation
Download Presentation
RDF for Developers

Loading in 2 Seconds...

play fullscreen
1 / 116

RDF for Developers - PowerPoint PPT Presentation


  • 95 Views
  • Uploaded on

Paul Groth. RDF for Developers. Thanks to Eyal Oren, Stefan Schlobach for slides. Contents. The Web of Data A Data Model A Query Language Query Time… Building Apps Exposing Data. Why can’t we query all the information on the Web as a database?. Data Interoperability on the Web.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'RDF for Developers' - gina


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
rdf for developers
Paul GrothRDF for Developers

Thanks to Eyal Oren, Stefan Schlobach for slides

contents
Contents
  • The Web of Data
  • A Data Model
  • A Query Language
  • Query Time…
  • Building Apps
  • Exposing Data
data interoperability on the web
Data Interoperability on the Web
  • Different formats, different structures, different vocabularies, different concepts, different meaning
  • Data should be structured (not ASCII)
  • Structure should be data-oriented (not HTML)
  • Meaning of data should be clear (not XML)
  • Data should have standard APIs (not Flickr)
  • Reusable mappings between data are needed (not XSLT)
what is the semantic web
What is the Semantic Web?

Tim Berners-Lee

“There is lots of data we all use every day, and it’s not part of the web. I can see my bank statements on the web, and my photographs, and I can see my appointments in a calendar. But can I see my photos in a calendar to see what I was doing when I took them? Can I see bank statement lines in a calendar?

No. Why not? Because we don’t have a web of data. Because data is controlled by applications and each application keeps it to itself.”

standard data model
Standard Data Model
  • RDF: basic data format (triples form hypergraph)
    • john likes mary .
    • isbn:10993 dc:title "The Pelican Brief" .
  • RDFS : simple schema language (subclass, subproperty)
    • dc:titlerdfs:subPropertyOfrdfs:label .
    • Jeep isa Car .
  • OWL: rich schema language (constraints, relations)
    • likes isaowl:symmetricProperty .
  • RDF allows interlinked graphs of arbitrary structure
  • RDFS and OWL allow inferencing of implicit information
standard api sparql
Standard API: SPARQL
  • Query language for RDF
    • Based on existing ideas (e.g. SQL)
    • Supported widely
  • Standard query protocol
    • How to send a query over HTTP
    • How to respond over HTTP
rdf data model summary
RDF Data Model: Summary
  • Resources
  • Triples
    • Statements: typed links between triples
    • May involve literals as property values
  • Graph
    • Set of Statements
    • Interlinked by reusing same URIsacrossed triples
rdf syntax
RDF Syntax
  • Several Different Formats
    • Standard RDF/XML
    • NTriples
    • Turtle
slide26
SQL?
  • Formulate a query on the relational model
    • students(name, age, address)
  • Structured Query Language (SQL)

SELECT namedata needed

FROM studentdata source

WHERE age>20data constraint

sparql1
SPARQL
  • Standard RDF query language
    • based on existing ideas
    • standardised by W3C
    • widely supported
  • Standard RDF query protocol
    • how to send a query over HTTP
    • how to respond over HTTP
sparql query syntax
SPARQL Query Syntax
  • SPARQL uses a select-from-where inspired syntax (like SQL):
  • select: the entities (variables) you want to return

SELECT ?city

  • from: the data source (RDF dataset)

FROM <http://example.org/geo.rdf>

  • where: the (sub)graph you want to get the information from

WHERE {?city geo:areacode “010” .}

  • Including additional constraints on objects, using operators

WHERE {?city geo:areacode ?c. FILTER (?c > 010)}

  • prologue: namespace information

PREFIX geo: <http://example.org/geo.rdf#>

sparql query syntax1
SPARQL Query Syntax

PREFIX geo: <http://example.org/geo/>

SELECT ?city

FROM <http://example.org/geoData.rdf>

WHERE {?citygeo:areacode ?c .

FILTER (?c > 010)

}

sparql graph patterns

EuropeanCountry

“020”^^xsd:integer

hasCapital

type

?

?

?

SPARQL Graph Patterns
  • The core of SPARQL
  • WHERE clause specifies graph pattern
    • pattern should be matched
    • pattern can match more than once
  • Graph pattern:
    • an RDF graph
    • with some nodes/edges as variables
basis triple patterns
Basis: triple patterns
  • Triples with one/more variables
  • Turtle syntax
    • ?X geo:hasCapitalgeo:Amsterdam
    • ?X geo:hasCapital ?Y
    • ?X geo:areacode "020"
    • ?X ?P ?Y
  • All of them match this graph:

areacode

hasCapital

Netherlands

Amsterdam

“020”

basis triple pattern
Basis: triple pattern
  • A very basic query

PREFIX geo: <http://example.org/geo/>

SELECT ?X

FROM <http://example.org/geoData.rdf>

WHERE { ?X geo:hasCapital ?Y .}

conjunctions several patterns
Conjunctions: several patterns
  • A pattern with several graphs, all must match

PREFIX geo: <http://example.org/geo/>

SELECT ?X

FROM <http://example.org/geoData.rdf>

WHERE { {?X geo:hasCapital ?Y }

{?Y geo:areacode "020" } }

equivalent to

PREFIX geo: <http://example.org/geo/>

SELECT ?X

FROM <http://example.org/geoData.rdf>

WHERE { ?X geo:hasCapital ?Y .

?Y geo:areacode "020" . }

conjunctions several patterns1
Conjunctions: several patterns
  • A pattern with several graphs, all must match

PREFIX geo: <http://example.org/geo/>

SELECT ?X

FROM <http://example.org/geoData.rdf>

WHERE { {?X geo:hasCapital ?Y }

{?Y geo:areacode "020" } }

equivalent to

PREFIX geo: <http://example.org/geo/>

SELECT ?X

FROM <http://example.org/geoData.rdf>

WHERE {

?X geo:hasCapital [ geo:areacode "020" ].

}

note turtle syntax again
Note: Turtle syntax again
  • ?X geo:name ?Y ; geo:areacode ?Z .
  • ?X geo:name ?Y . ?X geo:areacode ?Z .
  • ?country geo:capital [ geo:name “Amsterdam” ] .
alternative graphs union
Alternative Graphs: UNION
  • A pattern with several graphs, at least one should match

PREFIX geo: <http://example.org/geo/>

SELECT ?city

WHERE {

{ ?citygeo:name "Parijs"@nl }

UNION

{ ?citygeo:name "Paris"@fr .}

}

optional graphs
Optional Graphs
  • RDF is semi-structured
    • Even when the schema says some object can have a particular property, it may not always be present in the data
    • Example: persons can have names and email addresses, but Frank is a person without a known email address

name

person001

“Antoine”

email

“aisaac@few.vu.nl”

name

person002

“Frank”

optional graphs 2
Optional Graphs (2)
  • “Give me all people with first names, and if known their email address”
  • An OPTIONAL graph expression is needed

PREFIX : <http://example.org/my#>

SELECT ?person ?name ?email

WHERE {

?person :name ?name .

OPTIONAL { ?person :email ?email }

}

testing values of nodes
Testing values of nodes
  • Tests inFILTERclause have to be validated for matching subgraphs
  • RDF model-related operators
    • isLiteral(?aNode)
    • isURI(?aNode)
    • STR(?aResource)

Interest of STR?

SELECT ?X ?N

WHERE { ?X ?P ?N .

FILTER (STR(?P)="areacode") }

  • For resources with names only partly known
  • For literals with unknown language tags
testing values of nodes1
Testing values of nodes
  • Tests inFILTERclause
  • Comparison:
    • ?X <= ?Y, ?Z < 20, ?Z = ?Y, etc.
  • Arithmetic operators
    • ?X + ?Y, etc.
  • String matchingusing regular expressions
    • REGEX (?X,"netherlands","i")
      • matches"The Netherlands"

PREFIX geo: <http://example.org/geo/>

SELECT ?X ?N

WHERE { ?X geo:name ?N .

FILTER REGEX(STR(?N),"dam") }

filtering results
Filtering results
  • Tests in FILTER clause
    • Boolean combination of these test expressions
      • && (and), || (or), ! (not)
      • (?Y > 10 && ?Y < 30)

|| !REGEX(?Z,"Rott")

PREFIX geo: <http://example.org/geo/>

SELECT ?X

FROM <http://example.org/geo.rdf>

WHERE {?X geo:areacode ?Y ;

geo:name ?Z .

FILTER ((?Y > 10 && ?Y < 30) || !REGEX(STR(?X),"Rott")) }

boolean comparisons and datatypes
Boolean comparisons and datatypes
  • Reminder: RDF has basic datatypes for literals
    • XML Schema datatypes:xsd:integer, xsd:float, xsd:string, etc.
  • Datatypes can be used in value comparison
    • X < “21”^^xsd:integer
  • and be obtained from literals
    • DATATYPE(?aLiteral)
solution modifiers
Solution modifiers
  • ORDER BY

SELECT ?dog ?ageWHERE { ?dog a Dog ; ?dog :age ?age . } ORDER BY DESC(?age)

  • LIMITSELECT ?dog ?ageWHERE { ?dog a Dog ; ?dog :age ?age . }ORDER BY ?dogLIMIT 10
select query results
SELECT Query Results
  • SPARQL SELECT queries return solutions that consist of variable bindings
    • For each variable in the query, it gives a value (or a list of values).
    • The result is a table, where each column represents a variable and each row a combination of variable bindings
query result example
Query result: example
  • Query: “return all countries with the citiesthey contain, and their areacodes, if known”
  • Result (as table of bindings):

PREFIX geo: <http://example.org/geo/>

SELECT ?X ?Y ?Z

WHERE { ?X geo:containsCity ?Y.

OPTIONAL {?Y geo:areacode ?Z} }

select query results format
SELECT Query results: format
  • Query: return all capital cities
  • Results as an XML document :

PREFIX geo: <http://example.org/geo/>

SELECT ?X ?Y

WHERE { ?X geo:name ?Y .}

<sparqlxmlns="http://www.w3.org/2005/sparql-results#">

<head>

<variablename="X"/>

<variablename="Y"/>

</head>

<results>

<result>

<bindingname="X"><uri>http://example.org/Paris</uri></binding>

<bindingname="Y"><literal>Paris</literal></binding>

</result>

<result>

<bindingname="X"><uri>http://example.org/Paris</uri></binding>

<bindingname="Y"><literalxml:lang="nl">Parijs</literal></binding>

</result>

...

</results>

</sparql>

Header

Results

result formats
Result formats

<sparqlxmlns="http://www.w3.org/2005/sparql-results#">

<head>

<variable name="x"/>

<variable name="hpage"/>

</head>

<results>

<result>

<binding name=”x">

<literal datatype=”…/XMLSchema#integer">30</literal>

</binding>

<binding name="hpage">

<uri>http://work.example.org/bob/</uri>

</binding>

</result>

</results>

</sparql>

  • RDF/XML
  • N3
  • JSON
  • TEXT
query result forms
Query Result forms
  • SELECT queries return variable bindings
  • Do we need something else?
    • Statements from RDF original graph
      • Data extraction
    • New statements derived from original data according to a specific need
      • Data conversion, views over data
sparql construct queries
SPARQL CONSTRUCT queries
  • Construct-queries return RDF statements
    • The query result is either a subgraph of the original graph, or a transformed graph

Subgraph query:

PREFIX geo: <http://example.org/geo/>

CONSTRUCT {?X geo:hasCapital ?Y }

WHERE { ?X geo:hasCapital ?Y .

?Y geo:name "Amsterdam" }

hasCapital

Netherlands

Amsterdam

sparql construct queries1
SPARQL CONSTRUCT queries
  • Construct-queries return RDF statements
    • The query result is either a subgraph of the original graph, or a transformed graph

Transformation query:

PREFIX geo: <http://example.org/geo/>

PREFIX my: <http://example.org/myNS/>

CONSTRUCT {?Y my:inCountry ?X}

WHERE { ?X geo:hasCapital ?Y}

inCountry

Netherlands

Amsterdam

sparql queries
SPARQL queries
  • SELECT: table (variable bindings)select ?x where { … }
  • CONSTRUCT: graphconstruct { … } where { … }
  • ASK: yes/noask { … }
  • DESCRIBE: graphdescribe dbpedia:Amsterdam
conclusion
Conclusion
  • RDF is the data model
  • SPARQL is the query language
  • URIs enable data integration and information enrichment
sparql exercise
SPARQL Exercise
  • http://github.com/tialaramex/sparql-query
  • Try it on any sparql query endpoint
rdf conclusions revisited
RDF Conclusions revisited
  • Make explicit statements about resources on the web
  • Machine readable data
    • Machines know that these are statements
    • Machines know how statements relate resources
    • Machines can compare values
    • Machines can dereference URLs
a simple view of a web app
A Simple View of a Web App
  • Template with variables
    • <body> <p> $x </p></body>
  • Fill in the variables from a data source
    • $x = $db->get(“name”)
  • Parameters to query supplied by the user interface
  • Hard part: building the right query, and using the right data structure
a programmatic approach
A Programmatic Approach
  • LAMP stack
  • Use mySQL for data storage and query
  • Allows for procedural modification of data
  • Allows for integration of user input

What do we gain by this substitution?

slide62
APIs
  • PHP: RAP – RDF
    • http://www.seasr.org/wp-content/plugins/meandre/rdfapi-php/doc/
  • Python: RDFLib
    • http://www.rdflib.net/
  • C: Redland
    • http://librdf.org/
  • Java: Jena
    • http://jena.sourceforge.net/
slide63
APIs
  • PHP: RAP – RDF
    • http://www.seasr.org/wp-content/plugins/meandre/rdfapi-php/doc/
  • Python: RDFLib
    • http://www.rdflib.net/
  • C: Redland
    • http://librdf.org/
  • Java: Jena
    • http://jena.sourceforge.net/

SPARQL API

Graph API

sparql revisited
SPARQL Revisited

How do we parse these results?

sparql apis
SPARQL APIs
  • Build a string that contains the query
  • Execute the query on an endpoint
  • Results are returned as an array or iterator over key-value pairs
  • Usually some sort of basic type mapping, e.g. uri’s are turned into URI objects
  • Can access the variable names from the query
example in php
Example in PHP

$url = “http://example.net:2020/sparql”;

$query_str = “select * where {?s a ?o} limit 10;

$client =ModelFactory::getSparqlClient(url);

$query_obj = new ClientQuery();

$query_obj->query($query_str);

$results = $client->query($query_obj)

foreach($resultsas $line){
  $value = $line[’?s'];
 if($value != "")
     echo $value->toString()."<br>";
}

retrieving resources
Retrieving Resources
  • What if a resource is described outside of the database?
  • What if you want to work with all the data about a resource?
  • Solution:
    • Download (curl, urlget) the RDF graph of the resource
    • Then what…
slide68

dbowl:Country

a rdfs:Class ;

rdfs:label "countries" .

dbowl:capital

a rdf:Property ;

rdfs:label "countries capital" .

<http://localhost:2020/countries/USA>

a dbowl:Country ;

rdfs:label "countries #USA" ;

dbowl:capital "Washington D.C." ,

<http://www.dbpedia.org/resource/Washington D.C.> ;

vocab:hasName "USA" .

<http://localhost:2020/countries/Netherlands>

a dbowl:Country ;

rdfs:label "countries #Netherlands" ;

dbowl:capital "Amsterdam" , <http://www.dbpedia.org/resource/Amsterdam> ;

vocab:hasName "Netherlands" .

rdfs:label

a rdf:Property .

<http://localhost:2020/countries/Germany>

a dbowl:Country ;

rdfs:label "countries #Germany" ;

dbowl:capital "Berlin" , <http://www.dbpedia.org/resource/Berlin> ;

vocab:hasName "Germany" .

Do we work with this directly?

rdf is a graph so let s work with graphs
RDF is a graph…so let’s work with graphs

Netherlands

Db-owl: PopulatedPlace/capital

rdfs:label

Db:Amsterdam

“Netherlands”

neighbours

a

Db:Belgium

Country

a

a

Db-owl: City

@prefix Db: http://dbpedia.org/resource/

@prefix Db-owl: http://dbpedia.org/ontology/

graph model api
Graph Model API
  • Model = load(file)
  • Model.getResource(URI)
  • Resource Objects
    • StmtIter = listProperties()
    • StmtIter = getProperty(“property”)
  • Statement
    • Resource = Statement.getSubject()
    • Resource = Statement.getPredicate()
    • Resource = Statement.getObject()
  • Using these we can traverse the graph…
note on graphs
Note on Graphs
  • Remember objects may be literals
  • They also support building your own RDF model programmatically
    • Model.createResource(URL)
    • Resource.addProperty(value)
  • Many APIs also have “sparqlesque” languages for querying your data
  • This may be a way of mashing up your data
php example
PHP Example

// Get the netherlands resource

// don’t let create resource fool you
$netherlands = $model->createResource($netherlandsURL);

// Retrieve the value of the neighbor property
$statement = $netherlands->getProperty($neighbors);
$value = $statement->getObject();

// List the Neighbors of the Netherlands
echo '<b>Neighbors of '.$netherlands->getLabel().':</b><BR>';
foreach ($netherlands->listProperties($neighbors) as $country) 
{ 
    echo $country->getLabelObject().'<BR>';
};

what about ontologies
What about ontologies?
  • PopulatedPlace
    • City
      • Amsterdam
    • Country
      • Netherlands
      • Belgium
ontology models
Ontology Models
  • Provides methods for querying using a specific vocabulary
  • Generally, RDFS or OWL
  • Changes the perspective of a particular RDF Graph
  • You can use models both approaches simultaneously
ontology api
Ontology API
  • listNamedClassess()
  • listSubClass(Class)
  • getInstances(Class)
  • listProperties()
  • getDomain(Property)
  • getRange(Property)
  • getSubProperties(Property)
a note on ontology models
A note on ontology models
  • The model allow for navigation and creation not reasoning
  • Other inference- models can be used to perform reasoning
    • These may be expensive
    • Better to reasoning in a specialized store
slide77

When would you use an ontology model?

When would you use a graph model?

basic apis
Basic APIs
  • Performing Queries
    • sparql
  • Choosing the right data structure
    • Graph
    • Ontology
  • But..
    • You still have to build the template
    • You still have to interact with the user
    • You still have to create the queries
web frameworks and rdf
Web Frameworks and RDF
  • ActiveRDF
    • Ruby on Rails and RDF
    • http://www.activerdf.org/
  • Django and RDF
    • http://semanticdjango.org/
object rdf mapping
Object RDF Mapping
  • Equivalent to Object relational mapping
    • Multiple inheritance
    • Focus on properties
  • Python
    • RDF Alchemy
    • Surfrdf
  • Java
    • Elmo
    • jenabean
other apis
Other APIs
  • Sindice.com
    • Semantic web search engine
    • API for finding thins on the semantic web
  • Sameas.org
    • Expanding searches
    • Eliminating duplicates
  • Yahoo Boss
    • Live search engine
    • Find web pages with RDFa descriptions
  • OpenCalais
    • Entity extraction on text to linked data
other cool things
Other cool things
  • Javascript RDF parser
    • http://www.jibbering.com/rdf-parser/
  • PHP RDF Classes
    • http://arc.semsol.org/
  • Or just see…
    • http://esw.w3.org/topic/SemanticWebTools
we want rdf
We want RDF…

@prefix : <http://example.org/countries#> .

:Netherlands a :Country;

rdfs:label "TheNetherlands" ;

:capital :Amsterdam ;

:neighbours :Germany, :Belgium .

relational terminology
Relational Terminology

Relation/Table

Attribute

Country

Tuple

classes
Classes

Relation/Table

Attribute

  • Table is a class
  • But instances may have classes…
  • Don’t forget about keys…

Country

Tuple

properties
Properties

Relation/Table

Attribute

  • Attributes = properties
  • Watch out for naming (country? or label?)
  • What are the domain and range?

Country

Tuple

namespaces
Namespaces

Relation/Table

Attribute

  • What is the domain of your application?
  • What is the scope of your application?
  • http://example.org/countries#

Country

Tuple

uris and instances
URIs and instances

Relation/Table

Attribute

  • Tuple = instance
  • Objects = instances

Country

Tuple

an rdf model
An RDF Model

Netherlands

has_capital

rdfs:label

Amsterdam

“Netherlands”

neighbours

a

Belgium

Country

a

a

City

what have we gained
What have we gained?
  • Clear definition of types
  • Explicit definitions of relations
  • Graph queries with SPARQL
  • But… we are still not connected to the linked data cloud…

My

Source

linked data principles
Linked data principles
  • Use URIs as names of things
  • Use HTTP URIs so people can lookup stuff
  • Provide useful descriptions at your HTTP URIs
  • Include links to other URIs
  • See linkeddata.org
use external concepts and properties
Use External Concepts and Properties

Netherlands

Db-owl: PopulatedPlace/capital

rdfs:label

Db:Amsterdam

“Netherlands”

neighbours

a

Db:Belgium

Country

a

a

Db-owl: City

@prefix Db: http://dbpedia.org/resource/

@prefix Db-owl: http://dbpedia.org/ontology/

finding external ontologies
Finding External Ontologies

From http://semanticweb.org/wiki/Ontology

Also see prefix.cc

what have we gained 2
What have we gained? (2)
  • Clear definition of types
  • Explicit definitions of relations
  • Graph queries with SPARQL
  • An enriched data set!
practically use a mapping tool
Practically: Use a mapping tool
  • Triplify – http://triplify.org
  • Squirrel Rdf - http://jena.sourceforge.net/SquirrelRDF/
  • Virtuso RDF View
  • D2RQ - http://www4.wiwiss.fu-berlin.de/bizer/d2rq/
getting started with d2rq
Getting started with D2RQ
  • Download and install D2RQ server
    • http://www4.wiwiss.fu-berlin.de/bizer/d2r-server/
  • d2r-server-0.7/doc/example
  • Go through the quick start
  • Load a database into Mysql
    • Make one..
    • mysql < test.spl
creating a mapping file
Creating a Mapping File

> generate-mapping -o mapping.n3 –u db-user -p db-password jdbc:mysql://localhost/test

> d2r-server mapping.n3

rdf output
RDF Output

Defines a lot for us

mapping file preamble
Mapping File (Preamble)

@prefix map: <file:/Users/pgroth/Dropbox/develop/d2r-server-0.7/mapping.n3#> .

@prefix db: <> .

@prefix vocab: <http://localhost:2020/vocab/resource/> .

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

@prefix d2rq: <http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1#> .

@prefix jdbc: <http://d2rq.org/terms/jdbc/> .

map:database a d2rq:Database;

d2rq:jdbcDriver "com.mysql.jdbc.Driver";

d2rq:jdbcDSN "jdbc:mysql://localhost/test";

d2rq:username "root";

d2rq:password “****";

jdbc:autoReconnect "true";

jdbc:zeroDateTimeBehavior "convertToNull";

.

defining classes
Defining Classes
  • ClassMap defines classes
  • Attached to a particular database
  • Has a set of property bridges

# Table countries

map:countries a d2rq:ClassMap;

d2rq:dataStorage map:database;

d2rq:uriPattern "countries/@@countries.country|urlify@@";

d2rq:class vocab:countries;

d2rq:classDefinitionLabel "countries";

.

defining properties
Defining Properties
  • Map database columns to RDF properties
  • Example: Attaches a property capital to all countries

map:countries_country a d2rq:PropertyBridge;

d2rq:belongsToClassMap map:countries;

d2rq:property vocab:countries_country;

d2rq:propertyDefinitionLabel "countries country";

d2rq:column "countries.country";

.

map:countries_capital a d2rq:PropertyBridge;

d2rq:belongsToClassMap map:countries;

d2rq:property vocab:countries_capital;

d2rq:propertyDefinitionLabel "countries capital";

d2rq:column "countries.capital";

assigning identifiers
Assigning identifiers
  • countries/@@countries.country|urlify@@
  • 4 Mechanisms to assign identifiers to instances in a database

1. URI Pattern

    • http://example.org/countries/@@countries.country@@
    • @@ identifies the column to use
    • |urlify converts special characters for use in a URL
assigning identifiers 2
Assigning Identifiers (2)

2. Relative URIs

- countries/@@countries.country|urlify@@

- relative to the base URL

3. URI Columns

- if the column already has a uri

- use d2rq:uriColumns

4. Blank Nodes

- d2rq:bNodeIdColumns

- blank node per distinct set of values

updating a mapping file
Updating a Mapping File
  • Mapping files do not automatically link to linked data or external ontologies
  • Notice: @prefix vocab: <http://localhost:2020/vocab/resource/>
  • See http://www4.wiwiss.fu-berlin.de/bizer/d2rq/spec/
    • Many ways of making your mapping more expressive
ways to connect
Ways to Connect
  • Refer to external ontologies
    • @prefix dbowl: http://dbpedia.org/ontology/
    • d2rq:property dbowl:capital
    • d2rq:class dbowl:Country;
  • Refer to external items
    • d2rq:uriPattern http://www.dbpedia.org/resource/@@countries.capital@@;
use sameas
Use SameAs
  • Say that your concept is the “same as” another concept using owl:sameas
  • See http://sameas.org/
  • Has a special meaning so that systems no that your concept can be considered identical to another.
accessing the data
Accessing the data
  • Sparql Queries (on the fly)
  • Dumping the data to RDF
    • ./dump-rdf –m mapping.n3 -f N3 -b http://localhost:2020/ > test.nt
slide115

dbowl:Country

a rdfs:Class ;

rdfs:label "countries" .

dbowl:capital

a rdf:Property ;

rdfs:label "countries capital" .

<http://localhost:2020/countries/USA>

a dbowl:Country ;

rdfs:label "countries #USA" ;

dbowl:capital "Washington D.C." ,

<http://www.dbpedia.org/resource/Washington D.C.> ;

vocab:hasName "USA" .

<http://localhost:2020/countries/Netherlands>

a dbowl:Country ;

rdfs:label "countries #Netherlands" ;

dbowl:capital "Amsterdam" , <http://www.dbpedia.org/resource/Amsterdam> ;

vocab:hasName "Netherlands" .

rdfs:label

a rdf:Property .

<http://localhost:2020/countries/Germany>

a dbowl:Country ;

rdfs:label "countries #Germany" ;

dbowl:capital "Berlin" , <http://www.dbpedia.org/resource/Berlin> ;

vocab:hasName "Germany" .

databases rdf
Databases -> RDF
  • Allows us to integrate existing databases with the Semantic Web
  • Relational Model maps fairly directly to RDF
    • Caveats: No unique identifiers, lack of explicit ontological structure
  • Mapping Systems work well
  • Experiment with D2RQ!
    • It will be used in your final assignment