Menu
Home
Log in / Register
 
Home arrow Computer Science arrow Applied Big Data Analytics in Operations Management
Source

SPARQL

SPARQL is recommended by W3C in 2008 as semantic query language. SPARQL is similar to RDFs syntax and have conjunction and disjunction of data. SPARQL is widely used for semantic query. A simple SPARQL query to search all subject and object is

PREFIX rdf:

PREFIX owl:

PREFIX xsd:

PREFIX rdfs:

SELECT ?subject ?object

WHERE { ?cost rdfs:subClassOf ?object }

In the above code first four lines are used to specify the ontology and other namespace related information and vary from tool to tool. Whereas last two lines are used to fetch data from owl script and it is similar to SQL query structure with little difference in syntax. Select clause always contains subject and object name or its variable or aliases name. Condition is specified using Where clause that contains subject predicate and object. It can also have some expression using logical statements. For example

SELECT ?itemname ?price ?day WHERE { ?itemname a:price ?x .

  • ?x rdf:value ?price .
  • ?x p:day ?day. }

The above query returns itemname, its price and purchase day associated with each items in owl script. We can also put more constraint on query like

SELECT ?itemname ?price ?day WHERE { ?itemname a:price ?x .

  • ?x rdf:value ?price .
  • ?x p:day ?day.

FILTER(?day ==:mon)

}

Now this query returns all item purchased on Monday with its purchase cost. Same way can extract data from owl script.

 
Source
Found a mistake? Please highlight the word and press Shift + Enter  
< Prev   CONTENTS   Next >
 
Subjects
Accounting
Business & Finance
Communication
Computer Science
Economics
Education
Engineering
Environment
Geography
Health
History
Language & Literature
Law
Management
Marketing
Mathematics
Political science
Philosophy
Psychology
Religion
Sociology
Travel