SlideShare una empresa de Scribd logo
1 de 60
Descargar para leer sin conexión
An
                                  Introduction
                                            to
                                   Linked Data




                    Part 4 of 5              David Hyland-Wood
        SPARQL Query Language     University of Mary Washington

Monday, May 16, 2011
SPARQL:
                    A query
                language for RDF
Monday, May 16, 2011
SPARQL
                   • Query Language for RDF
                       http://www.w3.org/TR/rdf-sparql-query


                   • SPARQL Protocol and RDF Query
                       Language
                   • Graph pattern based language
                       written the same as Turtle


                   • Several queries — Ask; Select;
                       Describe; Construct
                   • Read Only
                       still vulnerable to injection, though not as bad as SQL



Monday, May 16, 2011
Queries
                   • ASK — True or False
                       Simple, Fast


                   • SELECT — Tabular data
                       easy to work with


                   • DESCRIBE — RDF
                       whatever the store has


                   • CONSTRUCT — RDF
                       Whatever you want




Monday, May 16, 2011
a              /discipline/            rdfs:label
            space:Discipline                                                                              Space Physics
                                                      spacephysics



                                                                              foaf:name
                                                                                                             Sputnik 1
                               space:discipline

                                                                            dc:description
                                                                                                  The Sputnik 1 spacecraft was ...


                                                                            space:agency
                                                                                                             U.S.S.R
                                        a              /spacecraft/
           space:Spacecraft
                                                       1957-001B             space:mass
                                                                                                               86.3




                                                                             foaf:depiction
                                                                                                /images/sputnik.jpg
                               space:spacecraft




                                                                            space:launched
                                                                                                            1957-10-04
                                        a
             space:Launch                           /launch/1957-001
                                                                          space:launchvehicle
                                                                                                     Modified SS-6 (Sapwood)


                                 space:launchsite


                                                                               rdfs:label
                                                                                                 Tyuratam (Baikonur Cosmodrome)
                                        a
           space:Launchsite                         /launchsite/tyurata
                                                                             space:country
                                                                                                             U.S.S.R




Monday, May 16, 2011
Triple Patterns




Monday, May 16, 2011
Triple Patterns

               <http://example.com/spacecraft/1957-001B>
                 foaf:name "Sputnik 1" .




Monday, May 16, 2011
Triple Patterns

               <http://example.com/spacecraft/1957-001B>
                 foaf:name "Sputnik 1" .


               ?something foaf:name "Sputnik 1" .




Monday, May 16, 2011
Triple Patterns

               <http://example.com/spacecraft/1957-001B>
                 foaf:name "Sputnik 1" .


               ?something foaf:name "Sputnik 1" .

               ?something foaf:name ?name .




Monday, May 16, 2011
Triple Patterns

               <http://example.com/spacecraft/1957-001B>
                 foaf:name "Sputnik 1" .


               ?something foaf:name "Sputnik 1" .

               ?something foaf:name ?name .

               ASK WHERE {
                 ?something foaf:name "Sputnik 1" .
               }




Monday, May 16, 2011
a             /discipline/            rdfs:label
            space:Discipline                                                                              Space Physics
                                                      spacephysics



                                                                              foaf:name
                                                                                                             Sputnik 1
                               space:discipline
                                                                            dc:description
                                                                                                  The Sputnik 1 spacecraft was ...


                                                                            space:agency
                                                                                                             U.S.S.R
                                         a             /spacecraft/
           space:Spacecraft
                                                       1957-001B             space:mass
                                                                                                               86.3




                                                                             foaf:depiction
                                                                                                /images/sputnik.jpg
                               space:spacecraft




                                                                            space:launched
                                                                                                            1957-10-04
                                         a
             space:Launch                           /launch/1957-001
                                                                          space:launchvehicle
                                                                                                     Modified SS-6 (Sapwood)


                                 space:launchsite


                                                                               rdfs:label
                                         a                                                       Tyuratam (Baikonur Cosmodrome)
           space:Launchsite                         /launchsite/tyurata
                                                                             space:country
                                                                                                             U.S.S.R




Monday, May 16, 2011
Triple Patterns
               PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

               ASK WHERE {
                 ?something rdfs:label ?label .
               }




Monday, May 16, 2011
a              /discipline/            rdfs:label
            space:Discipline                                                                              Space Physics
                                                      spacephysics



                                                                              foaf:name
                                                                                                             Sputnik 1
                               space:discipline

                                                                            dc:description
                                                                                                  The Sputnik 1 spacecraft was ...


                                                                            space:agency
                                                                                                             U.S.S.R
                                        a              /spacecraft/
           space:Spacecraft
                                                       1957-001B             space:mass
                                                                                                               86.3




                                                                             foaf:depiction
                                                                                                /images/sputnik.jpg
                               space:spacecraft




                                                                            space:launched
                                                                                                            1957-10-04
                                        a
             space:Launch                           /launch/1957-001
                                                                          space:launchvehicle
                                                                                                     Modified SS-6 (Sapwood)


                                 space:launchsite


                                                                               rdfs:label
                                                                                                 Tyuratam (Baikonur Cosmodrome)
                                        a
           space:Launchsite                         /launchsite/tyurata
                                                                             space:country
                                                                                                             U.S.S.R




Monday, May 16, 2011
a              /discipline/            rdfs:label
            space:Discipline                                                                              Space Physics
                                                      spacephysics



                                                                              foaf:name
                                                                                                             Sputnik 1
                               space:discipline

                                                                            dc:description
                                                                                                  The Sputnik 1 spacecraft was ...


                                                                            space:agency
                                                                                                             U.S.S.R
                                        a              /spacecraft/
           space:Spacecraft
                                                       1957-001B             space:mass
                                                                                                               86.3




                                                                             foaf:depiction
                                                                                                /images/sputnik.jpg
                               space:spacecraft




                                                                            space:launched
                                                                                                            1957-10-04
                                        a
             space:Launch                           /launch/1957-001
                                                                          space:launchvehicle
                                                                                                     Modified SS-6 (Sapwood)


                                 space:launchsite


                                                                               rdfs:label
                                                                                                 Tyuratam (Baikonur Cosmodrome)
                                        a
           space:Launchsite                         /launchsite/tyurata
                                                                             space:country
                                                                                                             U.S.S.R




Monday, May 16, 2011
Triple Patterns

               PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
               PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

               ASK WHERE {
                 ?something rdfs:label ?label ;
                   rdf:type space:Discipline .
               }




Monday, May 16, 2011
a              /discipline/            rdfs:label
            space:Discipline                                                                              Space Physics
                                                      spacephysics



                                                                              foaf:name
                                                                                                             Sputnik 1
                               space:discipline

                                                                            dc:description
                                                                                                  The Sputnik 1 spacecraft was ...


                                                                            space:agency
                                                                                                             U.S.S.R
                                        a              /spacecraft/
           space:Spacecraft
                                                       1957-001B             space:mass
                                                                                                               86.3




                                                                             foaf:depiction
                                                                                                /images/sputnik.jpg
                               space:spacecraft




                                                                            space:launched
                                                                                                            1957-10-04
                                        a
             space:Launch                           /launch/1957-001
                                                                          space:launchvehicle
                                                                                                     Modified SS-6 (Sapwood)


                                 space:launchsite


                                                                               rdfs:label
                                                                                                 Tyuratam (Baikonur Cosmodrome)
                                        a
           space:Launchsite                         /launchsite/tyurata
                                                                             space:country
                                                                                                             U.S.S.R




Monday, May 16, 2011
a              /discipline/            rdfs:label
            space:Discipline                                                                              Space Physics
                                                      spacephysics



                                                                              foaf:name
                                                                                                             Sputnik 1
                               space:discipline

                                                                            dc:description
                                                                                                  The Sputnik 1 spacecraft was ...


                                                                            space:agency
                                                                                                             U.S.S.R
                                        a              /spacecraft/
           space:Spacecraft
                                                       1957-001B             space:mass
                                                                                                               86.3




                                                                             foaf:depiction
                                                                                                /images/sputnik.jpg
                               space:spacecraft




                                                                            space:launched
                                                                                                            1957-10-04
                                        a
             space:Launch                           /launch/1957-001
                                                                          space:launchvehicle
                                                                                                     Modified SS-6 (Sapwood)


                                 space:launchsite


                                                                               rdfs:label
                                                                                                 Tyuratam (Baikonur Cosmodrome)
                                        a
           space:Launchsite                         /launchsite/tyurata
                                                                             space:country
                                                                                                             U.S.S.R




Monday, May 16, 2011
Triple Patterns

                       PREFIX space: <http://purl.org/net/schemas/space/>
                       PREFIX foaf: <http://xmlns.com/foaf/0.1/>

                       ASK WHERE {
                         ?spacecraft foaf:name “Sputnik 1” .
                         ?launch space:spacecraft ?spacecraft .
                         ?launch space:launched ?launchdate .
                       }




Monday, May 16, 2011
a              /discipline/            rdfs:label
            space:Discipline                                                                              Space Physics
                                                      spacephysics



                                                                              foaf:name
                                                                                                             Sputnik 1
                               space:discipline

                                                                            dc:description
                                                                                                  The Sputnik 1 spacecraft was ...


                                                                            space:agency
                                                                                                             U.S.S.R
                                        a              /spacecraft/
           space:Spacecraft
                                                       1957-001B             space:mass
                                                                                                               86.3




                                                                             foaf:depiction
                                                                                                /images/sputnik.jpg
                               space:spacecraft




                                                                            space:launched
                                                                                                            1957-10-04
                                        a
             space:Launch                           /launch/1957-001
                                                                          space:launchvehicle
                                                                                                     Modified SS-6 (Sapwood)


                                 space:launchsite


                                                                               rdfs:label
                                                                                                 Tyuratam (Baikonur Cosmodrome)
                                        a
           space:Launchsite                         /launchsite/tyurata
                                                                             space:country
                                                                                                             U.S.S.R




Monday, May 16, 2011
a              /discipline/            rdfs:label
            space:Discipline                                                                              Space Physics
                                                      spacephysics



                                                                              foaf:name
                                                                                                             Sputnik 1
                               space:discipline

                                                                            dc:description
                                                                                                  The Sputnik 1 spacecraft was ...


                                                                            space:agency
                                                                                                             U.S.S.R
                                        a              /spacecraft/
           space:Spacecraft
                                                       1957-001B             space:mass
                                                                                                               86.3




                                                                             foaf:depiction
                                                                                                /images/sputnik.jpg
                               space:spacecraft




                                                                            space:launched
                                                                                                            1957-10-04
                                        a
             space:Launch                           /launch/1957-001
                                                                          space:launchvehicle
                                                                                                     Modified SS-6 (Sapwood)


                                 space:launchsite


                                                                               rdfs:label
                                                                                                 Tyuratam (Baikonur Cosmodrome)
                                        a
           space:Launchsite                         /launchsite/tyurata
                                                                             space:country
                                                                                                             U.S.S.R




Monday, May 16, 2011
a              /discipline/            rdfs:label
            space:Discipline                                                                              Space Physics
                                                      spacephysics



                                                                              foaf:name
                                                                                                             Sputnik 1
                               space:discipline

                                                                            dc:description
                                                                                                  The Sputnik 1 spacecraft was ...


                                                                            space:agency
                                                                                                             U.S.S.R
                                        a              /spacecraft/
           space:Spacecraft
                                                       1957-001B             space:mass
                                                                                                               86.3




                                                                             foaf:depiction
                                                                                                /images/sputnik.jpg
                               space:spacecraft




                                                                            space:launched
                                                                                                            1957-10-04
                                        a
             space:Launch                           /launch/1957-001
                                                                          space:launchvehicle
                                                                                                     Modified SS-6 (Sapwood)


                                 space:launchsite


                                                                               rdfs:label
                                                                                                 Tyuratam (Baikonur Cosmodrome)
                                        a
           space:Launchsite                         /launchsite/tyurata
                                                                             space:country
                                                                                                             U.S.S.R




Monday, May 16, 2011
a              /discipline/            rdfs:label
            space:Discipline                                                                              Space Physics
                                                      spacephysics



                                                                              foaf:name
                                                                                                             Sputnik 1
                               space:discipline

                                                                            dc:description
                                                                                                  The Sputnik 1 spacecraft was ...


                                                                            space:agency
                                                                                                             U.S.S.R
                                        a              /spacecraft/
           space:Spacecraft
                                                       1957-001B             space:mass
                                                                                                               86.3




                                                                             foaf:depiction
                                                                                                /images/sputnik.jpg
                               space:spacecraft




                                                                            space:launched
                                                                                                            1957-10-04
                                        a
             space:Launch                           /launch/1957-001
                                                                          space:launchvehicle
                                                                                                     Modified SS-6 (Sapwood)


                                 space:launchsite


                                                                               rdfs:label
                                                                                                 Tyuratam (Baikonur Cosmodrome)
                                        a
           space:Launchsite                         /launchsite/tyurata
                                                                             space:country
                                                                                                             U.S.S.R




Monday, May 16, 2011
Example SELECT

               PREFIX space: <http://purl.org/net/schemas/space/>
               PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
               PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>


               SELECT ?subject ?label WHERE {

                       ?subject rdfs:label ?label ;
                                a space:Discipline .

               }




Monday, May 16, 2011
Example SELECT
               <sparql xmlns="http://www.w3.org/2005/sparql-results#">
                <head>
                 <variable name="subject"/>
                 <variable name="label"/>
                </head>
                <results>
                 <result>
                  <binding name="subject">
                    <uri>http://nasa.dataincubator.org/discipline/astronomy</
               uri>
                  </binding>
                  <binding name="label">
                    <literal>Astronomy</literal>
                  </binding>
                 </result>
                 <result>
                  <binding name="subject">
                    <uri>http://nasa.dataincubator.org/discipline/
               communications</uri>
                  </binding>
                  <binding name="label">
                    <literal>Communications</literal>
                  </binding>
                 </result>


Monday, May 16, 2011
Example SELECT

               PREFIX space: <http://purl.org/net/schemas/space/>
               PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
               PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>


               SELECT * WHERE {

                       ?subject rdfs:label ?label ;
                                a space:Discipline .

               }




Monday, May 16, 2011
a              /discipline/            rdfs:label
            space:Discipline                                                                              Space Physics
                                                      spacephysics



                                                                              foaf:name
                                                                                                             Sputnik 1
                               space:discipline

                                                                            dc:description
                                                                                                  The Sputnik 1 spacecraft was ...


                                                                            space:agency
                                                                                                             U.S.S.R
                                        a              /spacecraft/
           space:Spacecraft
                                                       1957-001B             space:mass
                                                                                                               86.3




                                                                             foaf:depiction
                                                                                                /images/sputnik.jpg
                               space:spacecraft




                                                                            space:launched
                                                                                                            1957-10-04
                                        a
             space:Launch                           /launch/1957-001
                                                                          space:launchvehicle
                                                                                                     Modified SS-6 (Sapwood)


                                 space:launchsite


                                                                               rdfs:label
                                                                                                 Tyuratam (Baikonur Cosmodrome)
                                        a
           space:Launchsite                         /launchsite/tyurata
                                                                             space:country
                                                                                                             U.S.S.R




Monday, May 16, 2011
Example SELECT DISTINCT

                       PREFIX space: <http://purl.org/net/schemas/space/>
                       PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
                       PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>


                       SELECT DISTINCT ?date WHERE {

                           ?launch space:launched ?date .

                       }




Monday, May 16, 2011
a              /discipline/            rdfs:label
            space:Discipline                                                                              Space Physics
                                                      spacephysics



                                                                              foaf:name
                                                                                                             Sputnik 1
                               space:discipline

                                                                            dc:description
                                                                                                  The Sputnik 1 spacecraft was ...


                                                                            space:agency
                                                                                                             U.S.S.R
                                        a              /spacecraft/
           space:Spacecraft
                                                       1957-001B             space:mass
                                                                                                               86.3




                                                                             foaf:depiction
                                                                                                /images/sputnik.jpg
                               space:spacecraft




                                                                            space:launched
                                                                                                            1957-10-04
                                        a
             space:Launch                           /launch/1957-001
                                                                          space:launchvehicle
                                                                                                     Modified SS-6 (Sapwood)


                                 space:launchsite


                                                                               rdfs:label
                                                                                                 Tyuratam (Baikonur Cosmodrome)
                                        a
           space:Launchsite                         /launchsite/tyurata
                                                                             space:country
                                                                                                             U.S.S.R




Monday, May 16, 2011
Example OPTIONAL

               PREFIX space: <http://purl.org/net/schemas/space/>
               PREFIX foaf: <http://xmlns.com/foaf/0.1/>


               SELECT ?name ?image WHERE {

                       ?spacecraft foaf:name ?name .

                       OPTIONAL {
                         ?spacecraft foaf:depiction ?image .
                       }
               }




Monday, May 16, 2011
Example OPTIONAL
               <?xml version="1.0"?>
               <sparql xmlns="http://www.w3.org/2005/sparql-results#">
                <head>
                 <variable name="name"/>
                 <variable name="image"/>
                </head>
                <results>
                 <result>
                  <binding name="name">
                   <literal>Soyuz 2</literal>
                  </binding>
                 </result>
                 <result>
                  <binding name="name">
                   <literal>Apollo 10</literal>
                  </binding>
                  <binding name="image">
                   <uri>http://nssdc.gsfc.nasa.gov/image/spacecraft/
               apollo_10_cm.jpg</uri>
                  </binding>
                 </result>




Monday, May 16, 2011
Example UNION

               PREFIX space: <http://purl.org/net/schemas/space/>
               PREFIX foaf: <http://xmlns.com/foaf/0.1/>
               PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>


               SELECT ?subject ?displayLabel WHERE {
                 {
                   ?subject foaf:name ?displayLabel .
                 }
                 UNION
                 {
                   ?subject rdfs:label ?displayLabel .
                 }
               }



Monday, May 16, 2011
Example UNION
               <?xml version="1.0"?>
               <sparql xmlns="http://www.w3.org/2005/sparql-results#">
                 <head>
                   <variable name="subject"/>
                   <variable name="displayLabel"/>
                 </head>
                 <results>
                   <result>
                     <binding name="subject">
                        <uri>http://nasa.dataincubator.org/spacecraft/ATLAS2</uri>
                     </binding>
                     <binding name="displayLabel">
                        <literal>Atlas 2</literal>
                     </binding>
                   </result>
                   <result>
                     <binding name="subject">
                        <uri>http://nasa.dataincubator.org/spacecraft/ATLAS3</uri>
                     </binding>
                     <binding name="displayLabel">
                        <literal>Atlas 3</literal>
                     </binding>
                   </result>




Monday, May 16, 2011
Example ORDER BY

               PREFIX space: <http://purl.org/net/schemas/space/>
               PREFIX foaf: <http://xmlns.com/foaf/0.1/>
               PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>


               SELECT ?name ?launchdate WHERE {
                 ?spacecraft foaf:name ?name .
                 ?launch space:spacecraft ?spacecraft .
                 ?launch space:launched ?launchdate .
               }




Monday, May 16, 2011
Example ORDER BY

               PREFIX space: <http://purl.org/net/schemas/space/>
               PREFIX foaf: <http://xmlns.com/foaf/0.1/>
               PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>


               SELECT ?name ?launchdate WHERE {
                 ?spacecraft foaf:name ?name .
                 ?launch space:spacecraft ?spacecraft .
                 ?launch space:launched ?launchdate .
               }
               ORDER BY DESC(?launchdate)




Monday, May 16, 2011
Example ORDER BY

               PREFIX space: <http://purl.org/net/schemas/space/>
               PREFIX foaf: <http://xmlns.com/foaf/0.1/>
               PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>


               SELECT ?name ?launchdate WHERE {
                 ?spacecraft foaf:name ?name .
                 ?launch space:spacecraft ?spacecraft .
                 ?launch space:launched ?launchdate .
               }
               ORDER BY DESC(?launchdate)
               LIMIT 10




Monday, May 16, 2011
Example ORDER BY

               PREFIX space: <http://purl.org/net/schemas/space/>
               PREFIX foaf: <http://xmlns.com/foaf/0.1/>
               PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>


               SELECT ?name ?launchdate WHERE {
                 ?spacecraft foaf:name ?name .
                 ?launch space:spacecraft ?spacecraft .
                 ?launch space:launched ?launchdate .
               }
               ORDER BY DESC(?launchdate)
               LIMIT 10
               OFFSET 10




Monday, May 16, 2011
Example FILTER

               PREFIX space: <http://purl.org/net/schemas/space/>
               PREFIX foaf: <http://xmlns.com/foaf/0.1/>
               PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>


               SELECT ?name WHERE {
                 ?launch space:launched ?date ;
                         space:spacecraft ?spacecraft .
                 ?spacecraft foaf:name ?name .

               FILTER (
                 ?date >= "1969-01-01"^^xsd:date &&
                 ?date <= "1969-12-31"^^xsd:date
                 )
               }


Monday, May 16, 2011
Example FILTER

               PREFIX space: <http://purl.org/net/schemas/space/>
               PREFIX foaf: <http://xmlns.com/foaf/0.1/>
               PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>


               SELECT ?spacecraft ?name WHERE {
                 ?spacecraft foaf:name ?name ;
                             space:mass ?mass .

                       FILTER( xsd:double(?mass) < 90.0 )
               }




Monday, May 16, 2011
Example FILTER

               PREFIX space: <http://purl.org/net/schemas/space/>
               PREFIX foaf: <http://xmlns.com/foaf/0.1/>
               PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>


               SELECT ?name WHERE {

                       ?spacecraft foaf:name ?name .

                       FILTER( regex(?name, “ollo”, “i” ) )
               }




Monday, May 16, 2011
Built-in Filters
                   •   Logical (!, &&, ||)
                   •   Math (+, -, *, /)
                   •   Comparison (=, !=, >, <, ...)
                   •   Tests
                       isURI, isBlank, isLiteral, bound, sameTerm, langMatches, regex


                   • Accessors
                       str, lang, datatype




Monday, May 16, 2011
Example NOT

               PREFIX space: <http://purl.org/net/schemas/space/>
               PREFIX foaf: <http://xmlns.com/foaf/0.1/>


               SELECT ?s WHERE {

                       ?s a space:Spacecraft .

                       OPTIONAL {
                         ?s foaf:depiction ?image .
                       }

                       FILTER ( !bound(?image) )
               }



Monday, May 16, 2011
Queries
                   • ASK — True or False
                       Simple, Fast


                   • SELECT — Tabular data
                       easy to work with


                   • DESCRIBE — RDF
                       whatever the store has


                   • CONSTRUCT — RDF
                       Whatever you want




Monday, May 16, 2011
Example DESCRIBE



    DESCRIBE <http://example.com/launch/1969-059>




Monday, May 16, 2011
Example DESCRIBE
    <rdf:RDF
        xmlns:space="http://purl.org/net/schemas/space/"
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >

    <rdf:Description
      rdf:about="http://nasa.dataincubator.org/launch/1969-059">
     <space:spacecraft
      rdf:resource="http://nasa.dataincubator.org/spacecraft/1969-059C"/>
     <space:spacecraft
      rdf:resource="http://nasa.dataincubator.org/spacecraft/1969-059B"/>
     <space:spacecraft
      rdf:resource="http://nasa.dataincubator.org/spacecraft/1969-059A"/>
     <space:launchvehicle>Saturn 5</space:launchvehicle>
     <space:launchsite
      rdf:resource="http://nasa.dataincubator.org/launchsite/capecana..."/>
     <space:launched
      rdf:datatype="http://www.w3.org/2001/XMLSchema#date">
        1969-07-16
     </space:launched>
     <rdf:type
      rdf:resource="http://purl.org/net/schemas/space/Launch"/>
    </rdf:Description>
    </rdf:RDF>



Monday, May 16, 2011
Example DESCRIBE

    PREFIX space: <http://purl.org/net/schemas/space/>
    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>


    DESCRIBE ?spacecraft WHERE {

          ?launch space:launched "1969-07-16"^^xsd:date .
          ?spacecraft space:launch ?launch .

    }




Monday, May 16, 2011
Example DESCRIBE
    <rdf:RDF
        xmlns:space="http://purl.org/net/schemas/space/"
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:foaf="http://xmlns.com/foaf/0.1/"
        xmlns:dc="http://purl.org/dc/elements/1.1/"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema#" >
      <rdf:Description rdf:about="http://nasa.dataincubator.org/spacecraft/1969-059B">
        <foaf:homepage rdf:resource="http://nssdc.gsfc.nasa.gov/database/MasterCatalog?
    sc=1969-059B"/>
        <dc:description>The...</dc:description>
        <space:mission rdf:resource="http://nasa.dataincubator.org/mission/apollo-11"/>
        <space:agency>United States</space:agency>
        <rdf:type rdf:resource="http://purl.org/net/schemas/space/Spacecraft"/>
        <space:launch rdf:resource="http://nasa.dataincubator.org/launch/1969-059"/>
        <space:discipline rdf:resource="http://nasa.dataincubator.org/discipline/
    planetaryscience"/>
        <space:alternateName>04040</space:alternateName>
        <space:alternateName>Apollo 11 Saturn V third stage</space:alternateName>
        <foaf:name>Apollo 11 SIVB</foaf:name>
        <space:internationalDesignator>1969-059B</space:internationalDesignator>
        <space:mass>13300.0</space:mass>
      </rdf:Description>

    ...




Monday, May 16, 2011
Example DESCRIBE

    PREFIX space: <http://purl.org/net/schemas/space/>
    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>


    DESCRIBE ?spacecraft ?launch WHERE {

          ?launch space:launched "1969-07-16"^^xsd:date .
          ?spacecraft space:launch ?launch .

    }




Monday, May 16, 2011
Example CONSTRUCT

    PREFIX space: <http://purl.org/net/schemas/space/>
    PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
    PREFIX foaf: <http://xmlns.com/foaf/0.1/>


    CONSTRUCT {
      ?spacecraft foaf:name ?name ;
                  space:agency ?agency ;
                  space:launched ?launchdate .
    }
    WHERE {
      ?spacecraft foaf:name ?name ;
                  space:agency ?agency .
      ?launch space:spacecraft ?spacecraft .
      ?launch space:launched ?launchdate .
    }




Monday, May 16, 2011
a              /discipline/            rdfs:label
            space:Discipline                                                                              Space Physics
                                                      spacephysics



                                                                              foaf:name
                                                                                                             Sputnik 1
                               space:discipline

                                                                            dc:description
                                                                                                  The Sputnik 1 spacecraft was ...


                                                                            space:agency
                                                                                                             U.S.S.R
                                        a              /spacecraft/
           space:Spacecraft
                                                       1957-001B             space:mass
                                                                                                               86.3




                                                                             foaf:depiction
                                                                                                /images/sputnik.jpg
                               space:spacecraft




                                                                            space:launched
                                                                                                            1957-10-04
                                        a
             space:Launch                           /launch/1957-001
                                                                          space:launchvehicle
                                                                                                     Modified SS-6 (Sapwood)


                                 space:launchsite


                                                                               rdfs:label
                                                                                                 Tyuratam (Baikonur Cosmodrome)
                                        a
           space:Launchsite                         /launchsite/tyurata
                                                                             space:country
                                                                                                             U.S.S.R




Monday, May 16, 2011
a             /discipline/            rdfs:label
            space:Discipline                                                                               Space Physics
                                                       spacephysics



                                                                               foaf:name
                                space:discipline                                                              Sputnik 1


                                                                             dc:description
                                                                                                   The Sputnik 1 spacecraft was ...


                                                                             space:agency
                                                                                                              U.S.S.R
                                          a             /spacecraft/
           space:Spacecraft
                                                        1957-001B             space:mass
                                                                                                                86.3




                                                                              foaf:depiction
                                                                                                 /images/sputnik.jpg
                               space:spacecraft




                                                                             space:launched
                                                                                                             1957-10-04
                                          a
             space:Launch                            /launch/1957-001
                                                                           space:launchvehicle
                                                                                                      Modified SS-6 (Sapwood)


                                  space:launchsite


                                                                                rdfs:label
                                                                                                  Tyuratam (Baikonur Cosmodrome)
                                          a
           space:Launchsite                          /launchsite/tyurata
                                                                              space:country
                                                                                                              U.S.S.R




Monday, May 16, 2011
a              /discipline/               rdfs:label
            space:Discipline                                                                                 Space Physics
                                                       spacephysics



                                                                                  foaf:name
                                                                                                                Sputnik 1
                               space:discipline
                                                                                dc:description
                                                                                                     The Sputnik 1 spacecraft was ...


                                                                                space:agency
                                                                                                                U.S.S.R
                                         a              /spacecraft/
           space:Spacecraft
                                                        1957-001B                space:mass
                                                                                                                  86.3




                                                                                 foaf:depiction
                                                                                                   /images/sputnik.jpg
                               space:spacecraft
                                                                           space:launched



                                                                               space:launched
                                                                                                               1957-10-04
                                         a
             space:Launch                            /launch/1957-001
                                                                             space:launchvehicle
                                                                                                        Modified SS-6 (Sapwood)


                                  space:launchsite


                                                                                   rdfs:label
                                         a                                                          Tyuratam (Baikonur Cosmodrome)
           space:Launchsite                          /launchsite/tyurata
                                                                                space:country
                                                                                                                U.S.S.R




Monday, May 16, 2011
Common Problems
                   • Typos
                       wrong case for property or class name


                   • wrong prefix URI
                       missing # or / or the URI for the web page


                   • Missing OPTIONAL
                       you won't even notice...


                   • Comparing Literals
                       Literals are compared on all of value, type and language




Monday, May 16, 2011
Tip 1: Find all the Properties

    SELECT DISTINCT ?p WHERE {

          ?s ?p ?o .

    }




Monday, May 16, 2011
a            /discipline/            rdfs:label
            space:Discipline                                                                             Space Physics
                                                     spacephysics



                                                                             foaf:name
                                                                                                            Sputnik 1
                               space:discipline

                                                                           dc:description
                                                                                                 The Sputnik 1 spacecraft was ...


                                                                           space:agency
                                                                                                            U.S.S.R
                                         a            /spacecraft/
           space:Spacecraft
                                                      1957-001B             space:mass
                                                                                                              86.3




                                                                            foaf:depiction
                                                                                               /images/sputnik.jpg
                               space:spacecraft




                                                                           space:launched
                                                                                                           1957-10-04
                                         a
             space:Launch                          /launch/1957-001
                                                                         space:launchvehicle
                                                                                                    Modified SS-6 (Sapwood)


                                space:launchsite


                                                                              rdfs:label
                                         a                                                      Tyuratam (Baikonur Cosmodrome)
           space:Launchsite                        /launchsite/tyurata
                                                                            space:country
                                                                                                            U.S.S.R




Monday, May 16, 2011
a                                    rdfs:label
                                                       /discipline/
            space:Discipline                                                                              Space Physics
                                                      spacephysics



                                                                              foaf:name
                                                                                                             Sputnik 1
                               space:discipline
                                                                            dc:description
                                                                                                  The Sputnik 1 spacecraft was ...


                                                                            space:agency
                                                                                                             U.S.S.R
                                          a            /spacecraft/
           space:Spacecraft
                                                       1957-001B             space:mass
                                                                                                               86.3




                                                                             foaf:depiction
                                                                                                /images/sputnik.jpg
                               space:spacecraft




                                                                            space:launched
                                          a                                                                 1957-10-04
             space:Launch                           /launch/1957-001
                                                                          space:launchvehicle
                                                                                                     Modified SS-6 (Sapwood)


                                 space:launchsite


                                                                               rdfs:label
                                          a                                                      Tyuratam (Baikonur Cosmodrome)
           space:Launchsite                         /launchsite/tyurata
                                                                             space:country
                                                                                                             U.S.S.R




Monday, May 16, 2011
Tip 2: Find all the Classes

    SELECT DISTINCT ?type WHERE {

          ?s a ?type .

    }




Monday, May 16, 2011
a            /discipline/            rdfs:label
            space:Discipline                                                                             Space Physics
                                                     spacephysics



                                                                             foaf:name
                                                                                                            Sputnik 1
                               space:discipline

                                                                           dc:description
                                                                                                 The Sputnik 1 spacecraft was ...


                                                                           space:agency
                                                                                                            U.S.S.R
                                         a            /spacecraft/
           space:Spacecraft
                                                      1957-001B             space:mass
                                                                                                              86.3




                                                                            foaf:depiction
                                                                                               /images/sputnik.jpg
                               space:spacecraft




                                                                           space:launched
                                                                                                           1957-10-04
                                         a
             space:Launch                          /launch/1957-001
                                                                         space:launchvehicle
                                                                                                    Modified SS-6 (Sapwood)


                                space:launchsite


                                                                              rdfs:label
                                         a                                                      Tyuratam (Baikonur Cosmodrome)
           space:Launchsite                        /launchsite/tyurata
                                                                            space:country
                                                                                                            U.S.S.R




Monday, May 16, 2011
a             /discipline/            rdfs:label
            space:Discipline                                                                               Space Physics
                                                       spacephysics



                                                                               foaf:name
                                                                                                              Sputnik 1
                                space:discipline

                                                                             dc:description
                                                                                                   The Sputnik 1 spacecraft was ...


                                                                             space:agency
                                                                                                              U.S.S.R
                                          a             /spacecraft/
           space:Spacecraft
                                                        1957-001B             space:mass
                                                                                                                86.3




                                                                              foaf:depiction
                                                                                                 /images/sputnik.jpg
                               space:spacecraft




                                                                             space:launched
                                                                                                             1957-10-04
                                          a
             space:Launch                            /launch/1957-001
                                                                           space:launchvehicle
                                                                                                      Modified SS-6 (Sapwood)


                                  space:launchsite


                                                                                rdfs:label
                                          a                                                       Tyuratam (Baikonur Cosmodrome)
           space:Launchsite                          /launchsite/tyurata
                                                                              space:country
                                                                                                              U.S.S.R




Monday, May 16, 2011
Thanks to


               • Rob Styles, Talis Group Ltd for his CC-BY
                 licensed “Two Day Introduction to the Web of
                 Data” slides and spacecraft example data.




Monday, May 16, 2011
This work is Copyright © 2010 David Hyland-Wood
                       Based partially on CC-BY licensed content Copyright © 2010 Talis Systems Limited by Rob Styles.
                       It is licensed under the Creative Commons Attribution 3.0 Unported License.
                       Full details at: http://creativecommons.org/licenses/by/3.0/


                       You are free:

                                  to Share — to copy, distribute and transmit the work




                                  to Remix — to adapt the work




                       Under the following conditions:
                                  Attribution. You must attribute the work in the manner specified by the author or licensor (but
                                  not in any way that suggests that they endorse you or your use of the work).



                       •   For any reuse or distribution, you must make clear to others the license terms of this work.
                       •   Any of the above conditions can be waived if you get permission from the copyright holder.
                       •   Nothing in this license impairs or restricts the author's moral rights.
                       •   Some Content in the work may be licensed under different terms, this is noted separately.




Monday, May 16, 2011

Más contenido relacionado

Más de David Wood

Internet of Things (IoT) two-factor authentication using blockchain
Internet of Things (IoT) two-factor authentication using blockchainInternet of Things (IoT) two-factor authentication using blockchain
Internet of Things (IoT) two-factor authentication using blockchainDavid Wood
 
Returning to Online Privacy?
Returning to Online Privacy?Returning to Online Privacy?
Returning to Online Privacy?David Wood
 
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...David Wood
 
BlockSW 2019 Keynote
BlockSW 2019 KeynoteBlockSW 2019 Keynote
BlockSW 2019 KeynoteDavid Wood
 
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221David Wood
 
Privacy in the Smart City
Privacy in the Smart CityPrivacy in the Smart City
Privacy in the Smart CityDavid Wood
 
Controlling Complexities in Software Development
Controlling Complexities in Software DevelopmentControlling Complexities in Software Development
Controlling Complexities in Software DevelopmentDavid Wood
 
Privacy Concerns related to Verifiable Claims
Privacy Concerns related to Verifiable ClaimsPrivacy Concerns related to Verifiable Claims
Privacy Concerns related to Verifiable ClaimsDavid Wood
 
Implementing the Verifiable Claims data model
Implementing the Verifiable Claims data modelImplementing the Verifiable Claims data model
Implementing the Verifiable Claims data modelDavid Wood
 
So You Wanna be a Startup CTO 20170301
So You Wanna be a Startup CTO 20170301So You Wanna be a Startup CTO 20170301
So You Wanna be a Startup CTO 20170301David Wood
 
Functional manipulations of large data graphs 20160601
Functional manipulations of large data graphs 20160601Functional manipulations of large data graphs 20160601
Functional manipulations of large data graphs 20160601David Wood
 
When Metaphors Kill
When Metaphors KillWhen Metaphors Kill
When Metaphors KillDavid Wood
 
Secularism in Australia
Secularism in AustraliaSecularism in Australia
Secularism in AustraliaDavid Wood
 
Meditations on Writing in Paradoxes, Oxymorons, and Pleonasms
Meditations on Writing in Paradoxes, Oxymorons, and PleonasmsMeditations on Writing in Paradoxes, Oxymorons, and Pleonasms
Meditations on Writing in Paradoxes, Oxymorons, and PleonasmsDavid Wood
 
Building a writer's platform with social media
Building a writer's platform with social mediaBuilding a writer's platform with social media
Building a writer's platform with social mediaDavid Wood
 
Summary of the Hero's Journey
Summary of the Hero's JourneySummary of the Hero's Journey
Summary of the Hero's JourneyDavid Wood
 
Open by Default
Open by DefaultOpen by Default
Open by DefaultDavid Wood
 
Lod Then, Now and Next 20110926
Lod Then, Now and Next 20110926Lod Then, Now and Next 20110926
Lod Then, Now and Next 20110926David Wood
 
Linked Data ROI 20110426
Linked Data ROI 20110426Linked Data ROI 20110426
Linked Data ROI 20110426David Wood
 
Introduction to Linked Data: RDF Vocabularies
Introduction to Linked Data: RDF VocabulariesIntroduction to Linked Data: RDF Vocabularies
Introduction to Linked Data: RDF VocabulariesDavid Wood
 

Más de David Wood (20)

Internet of Things (IoT) two-factor authentication using blockchain
Internet of Things (IoT) two-factor authentication using blockchainInternet of Things (IoT) two-factor authentication using blockchain
Internet of Things (IoT) two-factor authentication using blockchain
 
Returning to Online Privacy?
Returning to Online Privacy?Returning to Online Privacy?
Returning to Online Privacy?
 
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
Methods for Securing Spacecraft Tasking and Control via an Enterprise Ethereu...
 
BlockSW 2019 Keynote
BlockSW 2019 KeynoteBlockSW 2019 Keynote
BlockSW 2019 Keynote
 
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
Returning to Online Privacy - W3C/ANU Future of the Web Roadshow 20190221
 
Privacy in the Smart City
Privacy in the Smart CityPrivacy in the Smart City
Privacy in the Smart City
 
Controlling Complexities in Software Development
Controlling Complexities in Software DevelopmentControlling Complexities in Software Development
Controlling Complexities in Software Development
 
Privacy Concerns related to Verifiable Claims
Privacy Concerns related to Verifiable ClaimsPrivacy Concerns related to Verifiable Claims
Privacy Concerns related to Verifiable Claims
 
Implementing the Verifiable Claims data model
Implementing the Verifiable Claims data modelImplementing the Verifiable Claims data model
Implementing the Verifiable Claims data model
 
So You Wanna be a Startup CTO 20170301
So You Wanna be a Startup CTO 20170301So You Wanna be a Startup CTO 20170301
So You Wanna be a Startup CTO 20170301
 
Functional manipulations of large data graphs 20160601
Functional manipulations of large data graphs 20160601Functional manipulations of large data graphs 20160601
Functional manipulations of large data graphs 20160601
 
When Metaphors Kill
When Metaphors KillWhen Metaphors Kill
When Metaphors Kill
 
Secularism in Australia
Secularism in AustraliaSecularism in Australia
Secularism in Australia
 
Meditations on Writing in Paradoxes, Oxymorons, and Pleonasms
Meditations on Writing in Paradoxes, Oxymorons, and PleonasmsMeditations on Writing in Paradoxes, Oxymorons, and Pleonasms
Meditations on Writing in Paradoxes, Oxymorons, and Pleonasms
 
Building a writer's platform with social media
Building a writer's platform with social mediaBuilding a writer's platform with social media
Building a writer's platform with social media
 
Summary of the Hero's Journey
Summary of the Hero's JourneySummary of the Hero's Journey
Summary of the Hero's Journey
 
Open by Default
Open by DefaultOpen by Default
Open by Default
 
Lod Then, Now and Next 20110926
Lod Then, Now and Next 20110926Lod Then, Now and Next 20110926
Lod Then, Now and Next 20110926
 
Linked Data ROI 20110426
Linked Data ROI 20110426Linked Data ROI 20110426
Linked Data ROI 20110426
 
Introduction to Linked Data: RDF Vocabularies
Introduction to Linked Data: RDF VocabulariesIntroduction to Linked Data: RDF Vocabularies
Introduction to Linked Data: RDF Vocabularies
 

Último

UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17Celine George
 
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdfMaximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdfTechSoup
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17Celine George
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxKatherine Villaluna
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxraviapr7
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?TechSoup
 
How to Filter Blank Lines in Odoo 17 Accounting
How to Filter Blank Lines in Odoo 17 AccountingHow to Filter Blank Lines in Odoo 17 Accounting
How to Filter Blank Lines in Odoo 17 AccountingCeline George
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...raviapr7
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxEduSkills OECD
 
Latin American Revolutions, c. 1789-1830
Latin American Revolutions, c. 1789-1830Latin American Revolutions, c. 1789-1830
Latin American Revolutions, c. 1789-1830Dave Phillips
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17Celine George
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxSaurabhParmar42
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfYu Kanazawa / Osaka University
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICESayali Powar
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and stepobaje godwin sunday
 
How to Solve Singleton Error in the Odoo 17
How to Solve Singleton Error in the  Odoo 17How to Solve Singleton Error in the  Odoo 17
How to Solve Singleton Error in the Odoo 17Celine George
 
Patterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxPatterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxMYDA ANGELICA SUAN
 

Último (20)

UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024
 
How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17How to Add a many2many Relational Field in Odoo 17
How to Add a many2many Relational Field in Odoo 17
 
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdfMaximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
Maximizing Impact_ Nonprofit Website Planning, Budgeting, and Design.pdf
 
How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17How to Add Existing Field in One2Many Tree View in Odoo 17
How to Add Existing Field in One2Many Tree View in Odoo 17
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptx
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptx
 
What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?What is the Future of QuickBooks DeskTop?
What is the Future of QuickBooks DeskTop?
 
How to Filter Blank Lines in Odoo 17 Accounting
How to Filter Blank Lines in Odoo 17 AccountingHow to Filter Blank Lines in Odoo 17 Accounting
How to Filter Blank Lines in Odoo 17 Accounting
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
 
Latin American Revolutions, c. 1789-1830
Latin American Revolutions, c. 1789-1830Latin American Revolutions, c. 1789-1830
Latin American Revolutions, c. 1789-1830
 
Finals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quizFinals of Kant get Marx 2.0 : a general politics quiz
Finals of Kant get Marx 2.0 : a general politics quiz
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17
 
CAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptxCAULIFLOWER BREEDING 1 Parmar pptx
CAULIFLOWER BREEDING 1 Parmar pptx
 
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
 
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdfPersonal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICE
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and step
 
How to Solve Singleton Error in the Odoo 17
How to Solve Singleton Error in the  Odoo 17How to Solve Singleton Error in the  Odoo 17
How to Solve Singleton Error in the Odoo 17
 
Patterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptxPatterns of Written Texts Across Disciplines.pptx
Patterns of Written Texts Across Disciplines.pptx
 

Intro to Linked Data: SPARQL

  • 1. An Introduction to Linked Data Part 4 of 5 David Hyland-Wood SPARQL Query Language University of Mary Washington Monday, May 16, 2011
  • 2. SPARQL: A query language for RDF Monday, May 16, 2011
  • 3. SPARQL • Query Language for RDF http://www.w3.org/TR/rdf-sparql-query • SPARQL Protocol and RDF Query Language • Graph pattern based language written the same as Turtle • Several queries — Ask; Select; Describe; Construct • Read Only still vulnerable to injection, though not as bad as SQL Monday, May 16, 2011
  • 4. Queries • ASK — True or False Simple, Fast • SELECT — Tabular data easy to work with • DESCRIBE — RDF whatever the store has • CONSTRUCT — RDF Whatever you want Monday, May 16, 2011
  • 5. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) a space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 7. Triple Patterns <http://example.com/spacecraft/1957-001B> foaf:name "Sputnik 1" . Monday, May 16, 2011
  • 8. Triple Patterns <http://example.com/spacecraft/1957-001B> foaf:name "Sputnik 1" . ?something foaf:name "Sputnik 1" . Monday, May 16, 2011
  • 9. Triple Patterns <http://example.com/spacecraft/1957-001B> foaf:name "Sputnik 1" . ?something foaf:name "Sputnik 1" . ?something foaf:name ?name . Monday, May 16, 2011
  • 10. Triple Patterns <http://example.com/spacecraft/1957-001B> foaf:name "Sputnik 1" . ?something foaf:name "Sputnik 1" . ?something foaf:name ?name . ASK WHERE { ?something foaf:name "Sputnik 1" . } Monday, May 16, 2011
  • 11. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label a Tyuratam (Baikonur Cosmodrome) space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 12. Triple Patterns PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> ASK WHERE { ?something rdfs:label ?label . } Monday, May 16, 2011
  • 13. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) a space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 14. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) a space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 15. Triple Patterns PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> ASK WHERE { ?something rdfs:label ?label ; rdf:type space:Discipline . } Monday, May 16, 2011
  • 16. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) a space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 17. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) a space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 18. Triple Patterns PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> ASK WHERE { ?spacecraft foaf:name “Sputnik 1” . ?launch space:spacecraft ?spacecraft . ?launch space:launched ?launchdate . } Monday, May 16, 2011
  • 19. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) a space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 20. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) a space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 21. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) a space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 22. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) a space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 23. Example SELECT PREFIX space: <http://purl.org/net/schemas/space/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?subject ?label WHERE { ?subject rdfs:label ?label ; a space:Discipline . } Monday, May 16, 2011
  • 24. Example SELECT <sparql xmlns="http://www.w3.org/2005/sparql-results#"> <head> <variable name="subject"/> <variable name="label"/> </head> <results> <result> <binding name="subject"> <uri>http://nasa.dataincubator.org/discipline/astronomy</ uri> </binding> <binding name="label"> <literal>Astronomy</literal> </binding> </result> <result> <binding name="subject"> <uri>http://nasa.dataincubator.org/discipline/ communications</uri> </binding> <binding name="label"> <literal>Communications</literal> </binding> </result> Monday, May 16, 2011
  • 25. Example SELECT PREFIX space: <http://purl.org/net/schemas/space/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT * WHERE { ?subject rdfs:label ?label ; a space:Discipline . } Monday, May 16, 2011
  • 26. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) a space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 27. Example SELECT DISTINCT PREFIX space: <http://purl.org/net/schemas/space/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT DISTINCT ?date WHERE { ?launch space:launched ?date . } Monday, May 16, 2011
  • 28. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) a space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 29. Example OPTIONAL PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?name ?image WHERE { ?spacecraft foaf:name ?name . OPTIONAL { ?spacecraft foaf:depiction ?image . } } Monday, May 16, 2011
  • 30. Example OPTIONAL <?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#"> <head> <variable name="name"/> <variable name="image"/> </head> <results> <result> <binding name="name"> <literal>Soyuz 2</literal> </binding> </result> <result> <binding name="name"> <literal>Apollo 10</literal> </binding> <binding name="image"> <uri>http://nssdc.gsfc.nasa.gov/image/spacecraft/ apollo_10_cm.jpg</uri> </binding> </result> Monday, May 16, 2011
  • 31. Example UNION PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?subject ?displayLabel WHERE { { ?subject foaf:name ?displayLabel . } UNION { ?subject rdfs:label ?displayLabel . } } Monday, May 16, 2011
  • 32. Example UNION <?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#"> <head> <variable name="subject"/> <variable name="displayLabel"/> </head> <results> <result> <binding name="subject"> <uri>http://nasa.dataincubator.org/spacecraft/ATLAS2</uri> </binding> <binding name="displayLabel"> <literal>Atlas 2</literal> </binding> </result> <result> <binding name="subject"> <uri>http://nasa.dataincubator.org/spacecraft/ATLAS3</uri> </binding> <binding name="displayLabel"> <literal>Atlas 3</literal> </binding> </result> Monday, May 16, 2011
  • 33. Example ORDER BY PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?name ?launchdate WHERE { ?spacecraft foaf:name ?name . ?launch space:spacecraft ?spacecraft . ?launch space:launched ?launchdate . } Monday, May 16, 2011
  • 34. Example ORDER BY PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?name ?launchdate WHERE { ?spacecraft foaf:name ?name . ?launch space:spacecraft ?spacecraft . ?launch space:launched ?launchdate . } ORDER BY DESC(?launchdate) Monday, May 16, 2011
  • 35. Example ORDER BY PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?name ?launchdate WHERE { ?spacecraft foaf:name ?name . ?launch space:spacecraft ?spacecraft . ?launch space:launched ?launchdate . } ORDER BY DESC(?launchdate) LIMIT 10 Monday, May 16, 2011
  • 36. Example ORDER BY PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?name ?launchdate WHERE { ?spacecraft foaf:name ?name . ?launch space:spacecraft ?spacecraft . ?launch space:launched ?launchdate . } ORDER BY DESC(?launchdate) LIMIT 10 OFFSET 10 Monday, May 16, 2011
  • 37. Example FILTER PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT ?name WHERE { ?launch space:launched ?date ; space:spacecraft ?spacecraft . ?spacecraft foaf:name ?name . FILTER ( ?date >= "1969-01-01"^^xsd:date && ?date <= "1969-12-31"^^xsd:date ) } Monday, May 16, 2011
  • 38. Example FILTER PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT ?spacecraft ?name WHERE { ?spacecraft foaf:name ?name ; space:mass ?mass . FILTER( xsd:double(?mass) < 90.0 ) } Monday, May 16, 2011
  • 39. Example FILTER PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> SELECT ?name WHERE { ?spacecraft foaf:name ?name . FILTER( regex(?name, “ollo”, “i” ) ) } Monday, May 16, 2011
  • 40. Built-in Filters • Logical (!, &&, ||) • Math (+, -, *, /) • Comparison (=, !=, >, <, ...) • Tests isURI, isBlank, isLiteral, bound, sameTerm, langMatches, regex • Accessors str, lang, datatype Monday, May 16, 2011
  • 41. Example NOT PREFIX space: <http://purl.org/net/schemas/space/> PREFIX foaf: <http://xmlns.com/foaf/0.1/> SELECT ?s WHERE { ?s a space:Spacecraft . OPTIONAL { ?s foaf:depiction ?image . } FILTER ( !bound(?image) ) } Monday, May 16, 2011
  • 42. Queries • ASK — True or False Simple, Fast • SELECT — Tabular data easy to work with • DESCRIBE — RDF whatever the store has • CONSTRUCT — RDF Whatever you want Monday, May 16, 2011
  • 43. Example DESCRIBE DESCRIBE <http://example.com/launch/1969-059> Monday, May 16, 2011
  • 44. Example DESCRIBE <rdf:RDF xmlns:space="http://purl.org/net/schemas/space/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" > <rdf:Description rdf:about="http://nasa.dataincubator.org/launch/1969-059"> <space:spacecraft rdf:resource="http://nasa.dataincubator.org/spacecraft/1969-059C"/> <space:spacecraft rdf:resource="http://nasa.dataincubator.org/spacecraft/1969-059B"/> <space:spacecraft rdf:resource="http://nasa.dataincubator.org/spacecraft/1969-059A"/> <space:launchvehicle>Saturn 5</space:launchvehicle> <space:launchsite rdf:resource="http://nasa.dataincubator.org/launchsite/capecana..."/> <space:launched rdf:datatype="http://www.w3.org/2001/XMLSchema#date"> 1969-07-16 </space:launched> <rdf:type rdf:resource="http://purl.org/net/schemas/space/Launch"/> </rdf:Description> </rdf:RDF> Monday, May 16, 2011
  • 45. Example DESCRIBE PREFIX space: <http://purl.org/net/schemas/space/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> DESCRIBE ?spacecraft WHERE { ?launch space:launched "1969-07-16"^^xsd:date . ?spacecraft space:launch ?launch . } Monday, May 16, 2011
  • 46. Example DESCRIBE <rdf:RDF xmlns:space="http://purl.org/net/schemas/space/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" > <rdf:Description rdf:about="http://nasa.dataincubator.org/spacecraft/1969-059B"> <foaf:homepage rdf:resource="http://nssdc.gsfc.nasa.gov/database/MasterCatalog? sc=1969-059B"/> <dc:description>The...</dc:description> <space:mission rdf:resource="http://nasa.dataincubator.org/mission/apollo-11"/> <space:agency>United States</space:agency> <rdf:type rdf:resource="http://purl.org/net/schemas/space/Spacecraft"/> <space:launch rdf:resource="http://nasa.dataincubator.org/launch/1969-059"/> <space:discipline rdf:resource="http://nasa.dataincubator.org/discipline/ planetaryscience"/> <space:alternateName>04040</space:alternateName> <space:alternateName>Apollo 11 Saturn V third stage</space:alternateName> <foaf:name>Apollo 11 SIVB</foaf:name> <space:internationalDesignator>1969-059B</space:internationalDesignator> <space:mass>13300.0</space:mass> </rdf:Description> ... Monday, May 16, 2011
  • 47. Example DESCRIBE PREFIX space: <http://purl.org/net/schemas/space/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> DESCRIBE ?spacecraft ?launch WHERE { ?launch space:launched "1969-07-16"^^xsd:date . ?spacecraft space:launch ?launch . } Monday, May 16, 2011
  • 48. Example CONSTRUCT PREFIX space: <http://purl.org/net/schemas/space/> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> CONSTRUCT { ?spacecraft foaf:name ?name ; space:agency ?agency ; space:launched ?launchdate . } WHERE { ?spacecraft foaf:name ?name ; space:agency ?agency . ?launch space:spacecraft ?spacecraft . ?launch space:launched ?launchdate . } Monday, May 16, 2011
  • 49. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) a space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 50. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name space:discipline Sputnik 1 dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label Tyuratam (Baikonur Cosmodrome) a space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 51. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label a Tyuratam (Baikonur Cosmodrome) space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 52. Common Problems • Typos wrong case for property or class name • wrong prefix URI missing # or / or the URI for the web page • Missing OPTIONAL you won't even notice... • Comparing Literals Literals are compared on all of value, type and language Monday, May 16, 2011
  • 53. Tip 1: Find all the Properties SELECT DISTINCT ?p WHERE { ?s ?p ?o . } Monday, May 16, 2011
  • 54. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label a Tyuratam (Baikonur Cosmodrome) space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 55. a rdfs:label /discipline/ space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched a 1957-10-04 space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label a Tyuratam (Baikonur Cosmodrome) space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 56. Tip 2: Find all the Classes SELECT DISTINCT ?type WHERE { ?s a ?type . } Monday, May 16, 2011
  • 57. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label a Tyuratam (Baikonur Cosmodrome) space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 58. a /discipline/ rdfs:label space:Discipline Space Physics spacephysics foaf:name Sputnik 1 space:discipline dc:description The Sputnik 1 spacecraft was ... space:agency U.S.S.R a /spacecraft/ space:Spacecraft 1957-001B space:mass 86.3 foaf:depiction /images/sputnik.jpg space:spacecraft space:launched 1957-10-04 a space:Launch /launch/1957-001 space:launchvehicle Modified SS-6 (Sapwood) space:launchsite rdfs:label a Tyuratam (Baikonur Cosmodrome) space:Launchsite /launchsite/tyurata space:country U.S.S.R Monday, May 16, 2011
  • 59. Thanks to • Rob Styles, Talis Group Ltd for his CC-BY licensed “Two Day Introduction to the Web of Data” slides and spacecraft example data. Monday, May 16, 2011
  • 60. This work is Copyright © 2010 David Hyland-Wood Based partially on CC-BY licensed content Copyright © 2010 Talis Systems Limited by Rob Styles. It is licensed under the Creative Commons Attribution 3.0 Unported License. Full details at: http://creativecommons.org/licenses/by/3.0/ You are free: to Share — to copy, distribute and transmit the work to Remix — to adapt the work Under the following conditions: Attribution. You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). • For any reuse or distribution, you must make clear to others the license terms of this work. • Any of the above conditions can be waived if you get permission from the copyright holder. • Nothing in this license impairs or restricts the author's moral rights. • Some Content in the work may be licensed under different terms, this is noted separately. Monday, May 16, 2011