1 / 12

SPARQL : Simple Protocol and RDF Query Language

SPARQL : Simple Protocol and RDF Query Language. Speaker : 簡學群 Date : 2012 / 11 / 20. INTRODUCTION.

lacy
Download Presentation

SPARQL : Simple Protocol and RDF Query Language

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. SPARQL :Simple Protocol andRDF Query Language Speaker : 簡學群 Date : 2012 / 11 / 20

  2. Slides created by 簡學群, NCHU MIS 103 INTRODUCTION • SPARQL (Simple Protocol and RDF Query Language) defines standard query language and data access protocol which is used with RDF data model and it works for every data source which can be mapped to RDF which uses SPARQL to retrieve data. • SPARQL is to the Semantic Web (and, really, the Web in general) what SQL is to relational databases.

  3. Slides created by 簡學群, NCHU MIS 103 WHY SPARQL ? (2/3) • SPARQL saves development time and cost by allowing client applications to work with only the data they're interested in. • Eq. 查詢城市的人口、面積、房價,以判斷是否人口密度跟房價有關係。 • SPARQL is the only Semantic Query Language that is an official W3C Recommendation, and as such, has the greatest chance of actual standardization as the Semantic web grows.

  4. Slides created by 簡學群, NCHU MIS 103 ANATOMY of a QUERY

  5. Slides created by 簡學群, NCHU MIS 103 EXAMPLE - RDF <f:emp rdf:about="http://www.cems.uwe.ac.uk/empdept/emp/7499"> <f:EmpNordf:datatype="http://www.w3.org/2001/XMLSchema#string"> 7499 </f:EmpNo> <f:Salrdf:datatype="http://www.w3.org/2001/XMLSchema#integer"> 1600 </f:Sal> <f:HireDaterdf:datatype="http://www.w3.org/2001/XMLSchema#date"> 1998-08-15 </f:HireDate> <f:Mgrrdf:resource="http://www.cems.uwe.ac.uk/empdept/emp/7698"/> <f:MgrNo>7698</f:MgrNo> <f:Dept>Sales</f:Dept> <foaf:surname >ALLEN</foaf:surname> <f:Job>SALESMAN</f:Job> </f:emp>

  6. Slides created by 簡學群, NCHU MIS 103 EXAMPLE - List the names of all employees PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX f: <http://www.cems.uwe.ac.uk/empdept/concept/> PREFIX xs: <http://www.w3.org/2001/XMLSchema#> SELECT ?name WHERE { ?emprdf:type f:emp. ?empfoaf:surname ?name. } ORDER BY ?name subject predicate In SQL : SELECT name FROM employee ORDER BY name object

  7. Slides created by 簡學群, NCHU MIS 103 EXAMPLE - List the employees' name, salary, department, job SELECT ?name ?sal?dept ?job WHERE { ?emprdf:typef:emp. ?empfoaf:surname ?name. ?emp f:Sal ?sal. ?emp f:Dept ?dept. ?emp f:Job ?job. } In SQL : SELECT name, sal, dept, job FROM employee

  8. Slides created by 簡學群, NCHU MIS 103 EXAMPLE - List the top 5 employees by salary SELECT ?ename ?sal WHERE { ?emprdf:type f:emp. ?empfoaf:surname?ename. ?emp f:Sal ?sal. } ORDER BY DESC(?sal) LIMIT 5 In SQL : SELECT name, sal FROM employee ORDER BY sal DESC LIMIT 5

  9. Slides created by 簡學群, NCHU MIS 103 EXAMPLE - List the employees' name, salary, department, job SELECT ?ename ?mname WHERE { ?emprdf:type f:emp. ?emp f:Mgr ?mgr. ?empfoaf:surname?ename. ?mgrfoaf:surname?mname. } In SQL : SELECT emp.name, mgr.name FROM employee emp, employee mgr WHERE emp.mgr_id = mgr.emp_id

  10. Slides created by 簡學群, NCHU MIS 103 EXAMPLE - List the names of employees whose surname contains "AR" in Sales SELECT ?ename WHERE { ?emprdf:typef:emp. ?empf:Dept "Sales". ?empfoaf:surname?ename. FILTER (regex(?ename, "AR")) } In SQL : SELECT name FROM employee WHERE dept=“Sales” AND name LIKE “%AR%”

  11. Slides created by 簡學群, NCHU MIS 103 TOOLS • Twinkle: • http://www.ldodds.com/projects/twinkle/ • Virtuoso SPARQL Query Editor (web based) • http://dbpedia.org/sparql • SPARQL Engine • http://sourceforge.net/projects/sparql/

  12. Slides created by 簡學群, NCHU MIS 103 TOOLS - TWINQL

More Related