Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW -...

84
Prof. Massimo Ruffolo Ing. Ermelinda Oro

Transcript of Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW -...

Page 1: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Prof. Massimo Ruffolo Ing. Ermelinda Oro

Page 2: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Capitolo 4

RDF: Resource Description Framework RDFS: RDF Schema

Page 3: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF: Resource Description Framework

Page 4: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF: Resource Description Framework

The Resource Description Framework (RDF)

è uno standard W3C per la descrizione delle

risorse Web, in termini di titolo, autore, data

modifica, e copyright. È una piattaforma per la

descrizione delle risorse sul web

Page 5: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF – Esempi d’uso   Descrizione di proprietà di oggetti in vendita

come prezzo e disponibilità   Descrizione di informazioni relative a Pagine

Web: autore,modifica,copyright   Descrizione dei contenuti e classificazione di

immagini sul web   Descrizione di contenuti per facilitare il compito

dei motori di ricerca   Descrizione di librerie digitali

Page 6: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Proprietà di RDF 1.  RDF può essere interpretato da un computer RDF non è nato per essere letto dall’uomo 2.  RDF è scritto in XML

3.  RDF fa parte delle attività del W3C per il “Web Semantico”

4.  RDF è una “W3C Recommendation“

Page 7: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

1.RDF è disegnato per essere interpretato da un pc  RDF è stato disegnato per essere di

faci le interpretazione da parte di applicazioni che si occupano di trattare contenuti.

 RDF non è stato disegnato per essere visualizzato sul web

Page 8: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

2.RDF è scritto in XML

  Il linguaggio XML usato da RDF è chiamato RDF/XML.

 Usando XML, le informazioni RDF possono essere facilmente scambiate fra computer che ut i l izzino di fferent i piattaforme e differenti linguaggi di programmazione.

Page 9: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

3. RDF ed il “Web Semantico"

  Il linguaggio RDF fa parte del W3C's Semantic Web Activity. W3C's "Semantic Web Vision" mira ad un futuro in cui:

  Le risorse web siano esattamente descritte   Le risorse web possano essere estratte e

catalogate direttamente da un calcolatore   Le applicazioni possano automaticamente

incamerare e consumare contenuti eterogenei distribuiti sul web.

Page 10: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

4. RDF è un W3C Recommendation

  RDF è diventato un W3C Recommendation nel Febbraio 2004.

  Un “W3C Recommendation” è considerato all’interno della comunità internazionale come uno standard. Un W3C Recommendation è una specifica di un linguaggio del quale W3C dopo un attenta revisione ne dichiara la validità come standard.

  La W3C Specification per RDF si trova a questo link:

http://www.w3.org/RDF/

Page 11: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Risorse, Proprietà, e valori di Proprietà   RDF identifica gli oggetti attraverso una URI e

descrive tali oggetti attraverso le proprietà  Una Risorsa è tutto ciò che è identificato da un Uri.

Es. "http://www.w3schools.com/RDF"  Una proprietà è una risorsa cui viene associato un

nome come “mail” ,“name”  Il valore di una proprietà esprime il valore che una

proprietà di una risorsa può assumere. Il valore di una proprietà può essere un’altra risorsa.

Page 12: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Risorse, Proprietà, e valori di Proprietà: un esempio.

 L’RDF seguente descrive ad esempio la risorsa "http://www.unical.it/employee/mauri":

 Nell’esempio non è stato considerato alcun Namespace

Page 13: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Esempio Visivo

http://www.unical.it/employee/mauri

Maurizio

author

http://www.unical.it

homepage

Page 14: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Asserzioni   La combinazione di una risorsa, una proprietà ed un valore di proprietà si

chiama asserzione.   In un asserzione la risorsa viene chiamata Soggetto, la proprietà

Predicato ed il valore Oggetto.   Nell’esempio precedente:   Asserzione: “L’autore di http://www.unical.it/employee/mauri è Maurizio".

  Il soggetto è: http://www.unical.it/employee/mauri   Il predicato è: author   L’oggetto è: Maurizio

  Assrezione: “L’homePage di http://www.unical.it/employee/mauri è http://www.unical.it ".   Soggetto: http://www.unical.it/employee/mauri   Predicato: homepage   Oggetto: http://www.unical.it

Page 15: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Esempio Visivo

http://www.unical.it/employee/mauri

Maurizio

author

http://www.unical.it

homepage

Soggetto

Predicato

Oggetto

Predicato Oggetto

Asserzione

Page 16: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Esempio

  Collezione di CD:

Title Artist Country Company Price Year

Pearl Days Elisa Italia Columbia 12 euro 2006

Robbie Williams Misunderstood UK CBS Records 18 euro 2001

...

Page 17: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Esempio: Rappresentazione Grafica

http:// www.mp3.it/cd/Pearl Days

2006

year

Elisa

artist

Columbia company

12 euro

price

Page 18: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Esempi

Page 19: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Esempi   La prima linea è la dichiarazione XML. Segue la root di un

documento RDF: <rdf:RDF>.   Il xmlns:rdf namespace, specifica che all’interno del documento

tutto ciò che porta il prefisso rdf fa riferimento al namespace "http://www.w3.org/1999/02/22-rdf-syntax-ns#".

  Il xmlns:cd namespace, specifica che all’interno del documento tutto ciò che porta il prefisso cd fa riferimento al namespace http://www.mp3.it/cd#“ .

  Il tag <rdf:Description> specifica la descrione della risorsa identificata dall’attibuto rdf:about.

  Gli elementi: <cd:artist>, <cd:country>, <cd:company>, etc. sono proprietà della risorsa.

Page 20: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Esempi dichiarazione XML

xmlns:rdf namespace, ciò che porta il prefisso rdf fa riferimento al namespace

<rdf:Description> specifica la descrione della risorsa identificata dall’attibuto rdf:about.

proprietà della risorsa

ROOT doc RDF

Page 21: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

L’elemento <rdf:RDF>   <rdf:RDF> è la root di qualsiasi documento RDF e lo

identifica: in esso può essere contenuto il riferimento al namesapce RDF

  <?xml version="1.0"?> <rdf:RDF xmlns:rdf="http://www.w3.org/

1999/02/22-rdf-syntax-ns#"> [descrizioni delle risorse]

</rdf:RDF>

Page 22: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

L’ elemento <rdf:Description>

  L’ <rdf:Description> identifica una risorsa ed i suoi attributi

  L’ <rdf:Description> contiene elementi che descrivono le sue proprietà

  Gli elementi, artist, country, company, price, e year, sono definiti nel namespace http://www.mp3.it/cd#. Questo namespace non ha nulla a che fare con RDF . RDF definisce solo l’infrastruttura.

Page 23: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Proprietà come Attributi   Le proprietà possono essere rappresentate come attributi

Page 24: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Proprietà come Risorse  I valori di proprietà possono essere

espressi come risorse:

 La proprietà artista non ha un valore ma un riferimento ad un’altra risorsa.

Page 25: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Proprietà come Risorse

http:// www.mp3.it/cd/Pearl Days

2006

year

artist

Columbia company

12 euro

price

http:// www.mp3.it/artist/Elisa

Elisa name

Page 26: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Elementi contenitori

  RDF containers: sono usati per descrivere gruppi di

cose. Ad esempio per elencare gli autori di un disco o

di una canzone.

  Per descrivere questi gruppi si usano i tag:

  <Bag>,

  <Seq>, e

  <Alt>.

Page 27: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

L’elemento <rdf:Bag>   Rappresenta una lista di valori non ordinata.   Può contenere valori duplicati.

 Esempio

Page 28: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

rdf:Bag

http:// www.mp3.it/song/

Ostacoli del cuore

rdf:type

Elisa

rdf:_1

Ligabue

rdf:_2

rdf:Bag

cd:artist

Page 29: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

L’elemento <rdf:Seq>   Rappresenta un lista di valori ordinata   Può contenere valori duplicati.

  Esempio

Page 30: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

rdf:Seq

http:// www.mp3.it/

cd/Pearl Days

rdf:type

01 Stay rdf:_1

02 Gli Ostacoli del cuore

rdf:_2

rdf:Seq

cd:songs

. . . .

rdf:_3

Page 31: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

L’elemento <rdf:Alt>   Rappresenta una lista di alternative   Esempio

Page 32: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

rdf:Alt

http:// www.mp3.it/

song/Ostacoli del cuore

rdf:type CD

rdf:_1

Disco

rdf:_2

rdf:Alt

cd:format

MC

rdf:_3

Page 33: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Terms

 Una lista di valori in RDF si chiamano membri.

 Quindi:  Un contenitore è una risorsa che contiene

altri oggetti  Gli oggetti contenuti in un contenitore- lista

si chiamano membri.

Page 34: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Collections

 RDF collections sono usati per descrivere gruppi che contengono solo gli elementi specificati.

Page 35: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

L’attributo rdf:parseType="Collection"   Un container dice che una risorsa contiene alcuni membri ma tale

affermazione non è chiusa: può contenerne anche altri.   RDF collections è usato per esprimere liste chiuse

  Una collezione è descritta dall’attibuto rdf:parseType="Collection".  Example

Page 36: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDFS: Resource Description Framework Schema

Page 37: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Schema e Classi   RDF descrive risorse tramite classi, proprietà e valori.   RDF ha bisogno di definire delle classi e proprietà

specifiche per un applicazione

  Queste classi devono essere definite usando un estensione di RDF

  Tale estensione è RDF Schema   RDF Schema (RDFS) è un estensione di RDF

Page 38: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Schema (RDFS)   RDF Schema non ha classi predefinite.   RDF Schema fornisce la piattaforma per descrivere nuovi tipi di

classi.   Le classi in RDF Schema sono simili alle classi di un linguaggio di

programmazione ad oggetti.   In RDF si possono rappresentare le risorse come istanze di classi

e definire sottoclassi e tipi.

Page 39: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Classi e Proprietà   Namespace prefix:'rdfs' URI:'http://www.w3.org/

2000/01/rdf-schema#'   Le risorse possono essere istanze di una o più classi   La classe è indicata tramite l’attibuto rdf:type

  La risorsa http://www.unical.it/students/Maurizio è rdf:type Student

  La risorsa http://www.unicla.it/students/Maurizio è rdf:type Person

 Student è rdfs:subClassOf Person

  Le proprietà vengono definite in funzione della classe di risorse su cui si applicano

Page 40: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Classi

 rdfs:Resource – le risorse sono istanze di questa classe

 rdfs:Property – le proprietà sono istanze di questa classe.

 rdfs:Class – una classe dei linguaggi object oriented.

Page 41: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Proprietà   rdf:type – indica che una risorsa è del tipo della

classe che viene specificata   rdfs:subClassOf – indica la relazione classe/

sottoclasse fra due classi   rdfs:subPropertyOf – indica che una proprietà e

specializzazione di un’altra.   rdfs:seeAlso – specifica che la risorsa è anche

descritta in altre parti   rdfs:isDefinedBy – indica la risorsa “soggetto

dell’asserzione” ovvero chi ha fatto l’asserzione

Page 42: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDFS Esempi   Classi e Sotto classi:

La classe horse viene dichiarata come sottoclasse della classe Animal.

Page 43: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Esempio Abbreviato   RDFS Class è sotto classe della classe

rdf:Resource. Per questo motivo possiamo evitare di usare rdf:Description rdf:type ed usare direttamente rdfs:class

Page 44: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Esempio Abbreviato   RDFS Class è sotto classe della classe

rdf:Resource. Per questo motivo possiamo evitare di usare rdf:Description rdf:type ed usare direttamente rdf:class

Page 45: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Constraints: range e domain   rdfs:range

 Indica la classe dei valori ammissibili di una proprietà.

 rdfs:range è una classe rdfs:Class

  rdfs:domain  Indica la classe a cui la proprietà si applica

 Se non è specificata indica che quella proprietà può essere usata su qualsiasi classe.

Page 46: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Constraints: range e domain   Legame tra classi e proprietà

  RDF(S) fornisce anche un vocabolario per descrivere come ci si aspetta che proprietà e classi si combinino tra di loro

  Proprietà predefinite rdfs:domain ed rdfs:range

http:// www.mp3.it/cd/#Artist

http:// www.mp3.it/cd/#singer

http://www.w3.org/1999/02/22-rdf-syntax-ns#Property

rdf:type

http:// www.mp3.it/cd/#Song

rdfs:domain rdfs:range

valori ammissibili classe a cui

la proprietà si applica

Page 47: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Documentation   rdfs:comment – testo libero   rdfs:label – Riporta informazioni sulla versione

di una risorsa

Page 48: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Schema Esempio (1)

Page 49: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Schema Esempio (2)

Page 50: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Schema Esempio (3)

Page 51: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Istanze – classi – metaclassi

rdfs:Class rdfs:Resource

rdfs:subClassOf

rdf:type

rdf:type

terms:Person

terms:Students

terms:Course

rdf:type

rdfs:subClassOf

people:Ruffolo course:BDSIW

rdf:type

terms:teacher

Massimo terms:name

rdf:type

terms:Teacher

people:Bianchi Mario terms:name

Page 52: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Reasoning

rdfs:Class rdfs:Resource

rdfs:subClassOf

rdf:type

rdf:type

terms:Person

terms:Students

terms:Course

rdf:type

rdfs:subClassOf

people:Ruffolo course:BDSIW

rdf:type

terms:teacher

Massimo terms:name

rdf:type

terms:Teacher

people:Bianchi Mario terms:name

rdfs:subClassOf

rdf:type

Page 53: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF Esempio

Page 54: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Modello generale

rdf:type

terms:…

terms:…

rdfs:subClassOf rdfs:Class

rdf:type

rdfs:Resource

rdfs:subClassOf

rdf:type

rdfs:Property

rdf:domain

terms:…

terms:…

rdfs:range

terms:…

Page 55: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Interrogazione di file RDF SPARQL, linguaggio di interrogazione dell' RDF

del W3C, è stato accolto entusiasticamente

come l'agognato ultimo tassello per l'edificazione

del Web semantico

Page 56: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

SPARQL Sintassi Turtle SPARQL adotta la sintassi Turtle, un'estensione di N-Triples, alternativa estremamente sintetica e intuitiva al tradizionale RDF/XML.

@prefix cd: http://example.org/cd/ @prefix: http://example.org/example

:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore "Autechre". :Amber cd:anno 1994.

Si considerino le seguenti triple RDF, che saranno utilizzate nel corso della lezione come riferimento per le query d'esempio:

Page 57: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

RDF File cd.rdf

Page 58: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Query SPARQL

 PREFIX cd: <http://example.org/cd/> SELECT ?title ?artist ?year FROM <cd.rdf> WHERE {?title cd:artist ?artist. ?title cd:year ?year . }

Page 59: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Risultato

Title Artist Year

Pearl Days Elisa 2006

Restituisce tutte le risorse per le quali sia specificato sia l’artista che l’anno

Page 60: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Clausola OPTIONAL

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

SELECT ?title ?artist ?year

FROM <cd.rdf>

WHERE { ?title cd:artist ?artist.

OPTIONAL {?title cd:year ?year.}

}

Page 61: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Risultato

Title Artist Year

Pearl Days Elisa 2006

Misunderstood Robbie Williams

Restituisce tutte le risorse per le quali sia specificato l’artista e opzionalmente l’anno

Page 62: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Clausola UNION

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

SELECT ?title ?artist ?price ?year

  FROM <cd.rdf>

WHERE {

{?title cd:year ?year.}

UNION

{?title cd:price ?price.}

}

Page 63: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Risultato

Title Artist Price Year

Pearl Days Elisa 2006

Misunderstood Robbie Williams 18 euro

Restituisce tutte le risorse per le quali sia specificato o il prezzo o l’anno.

Page 64: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Clausola FILTER

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

SELECT ?title ?artist ?price ?year

  FROM <cd.rdf>

WHERE { {?title cd:year ?year.}

FILTER (?year > 2005)

}

Page 65: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Risultato

Title Artist Price Year

Pearl Days Elisa 2006

Restituisce tutte le risorse per le quali l’attributo anno è maggiore di 2005.

Page 66: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Clausola FILTER con REGEX

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

SELECT ?title ?artist

  FROM <cd.rdf>

WHERE { {?title cd:artist ?artist.}

FILTER regex(?artist, “^el”, “i” )

}

Page 67: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Risultato

Title Artist

Pearl Days Elisa

Restituisce tutte le risorse per le quali l’attributo artist comincia per “el” ignorando la distinzione fra maiuscole e minuscole.

Page 68: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Costrutti speciali

 SELECT DISTINCT ?title ?artist  ORDER BY DESC(?autore)

 LIMIT 10  OFFSET 10

Page 69: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Esempio 2: Human Ontology (Classes)

Animal

Female Male Person

Woman Man Researcher Lecturer

rdfs:subClassOf

rdfs:subClassOf

rdfs:subClassOf

rdfs:subClassOf

rdfs:subClassOf

rdfs:subClassOf

rdfs:subClassOf

rdfs:subClassOf rdfs:subClassOf

Page 70: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Esempio 2: Human Ontology (ObjectProperty)

Animal

Male

rdfs:range

rdfs:domain

hasAncestor

Animal

hasParent

hasFather

rdfs:subPropertyOf

rdfs:range hasMother

Female

rdfs:subPropertyOf

rdfs:subPropertyOf

rdfs:range

Animal

rdfs:range

rdfs:domain

hasBrother

Male

Animal

rdfs:range

rdfs:domain

hasSister

Female

Person

rdfs:range

rdfs:domain

hasFriend

Person

Person

rdfs:range

rdfs:domain

hasSpouse

Person

Page 71: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Esempio 2: Human Ontology (DataType Property)

Animal

rdfs:range

rdfs:domain

age

Integer

Person

rdfs:range

rdfs:domain

trouserssize

Integer

Person

rdfs:range

rdfs:domain

shirtSize

Integer

Person

rdfs:range

rdfs:domain

name

String

Page 72: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Istanze

Harry

Man isA

Sophie

John

hasChild

hasSpouse

Person isA

14

37 shoeSize

age

Mark 16

39 shoeSize

age

hasFather

Eve

Lecturer

David

hasSpouse

hasFriend

Alice

Researcher

isA

isA

isA

hasFriend

Gastone

hasFriend

Jack

hasFriend

hasChild (…)

Page 73: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Query su Classi

SELECT ?x WHERE { ?x rdf:type rdfs:Class }

Page 74: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Sussunzioni

SELECT ?x ?y WHERE { ?x rdfs:subClassOf ?y }

Page 75: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Proprietà: Persone Sposate

SELECT ?x ?y WHERE { ?x humans:hasSpouse ?y }

Page 76: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Uomini Sposati

SELECT * WHERE { ?x humans:hasSpouse ?y . ?x rdf:type humans:Male }

Page 77: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Numero di Persone di cui Y è amico

SELECT ?x ?y count(?x) as ?conteggio group ?y WHERE { ?x humans:hasFriend ?y }

Page 78: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Persone con almeno un parente

SELECT DISTINCT ?x WHERE { { ?y humans:hasChild ?x } UNION { ?x humans:hasParent ?y } }

Page 79: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Le persone e la loro età (se nota)

SELECT ?person ?age WHERE { ?person rdf:type humans:Person OPTIONAL { ?person humans:age ?age } }

Page 80: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Maggiorenni

SELECT ?x WHERE { ?x humans:age ?age FILTER ( xsd:integer(?age) >= 18 ) }

Page 81: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

E’ Mark Maggiorenne?

ASK WHERE {

#Mark humans:age ?age FILTER ( xsd:integer(?age) >= 18 )

}

Page 82: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Tutte le persone che non sono ricercatori.

SELECT ?x WHERE { ?x rdf:type humans:Person OPTIONAL { ?x rdf:type ?t FILTER ( ?t = humans:Researcher ) } FILTER ( ! bound( ?t ) ) }

Page 83: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Antenati

SELECT ?x ?y

WHERE { ?x humans:hasAncestor ?y }

Questa query restituisce ovviamente, anche tutte le istanze delle

sottoproprietà hasFather ed HasParent

Page 84: Prof. Massimo Ruffolo Ing. Ermelinda Orostaff.icar.cnr.it/ruffolo/BDSIW-2010/09-10 - BDSIW - E2...:Permutation cd:autore "Amon Tobin". :Bricolage cd:autore "Amon Tobin". :Amber cd:autore

Bibliografia

  RDF/RDFS SPECIFICATION

  http://www.w3.org/RDF/

  Semantic web tutorial: RDF, RDFS and SPARQL using CORESE

  http://www-sop.inria.fr/acacia/soft/corese/tutorial.php

  CORESE (Open Source Software per interrogare file RDF)

  http://www-sop.inria.fr/teams/edelweiss/wiki/wakka.php?wiki=Corese