Ontology SPARQL basic query

Please Share This Article with Friends

What are the advantages of SPARQL?

  • SPARQL can fetch results/data from structured and semi-structured data.
  • SPARQL can handle complex joins and relationships
  • SPARQL can help to find the data by running queries of unknown relationships.
  • SPARQL can transform RDF data into different vocabulries.

What is mean by RDF triples?

RDF triples are

  1. Subject
  2. Predicate
  3. Object

What are literals?

Literal is the lexical representation of values such as numbers and dates. 

A literal can be the object but it can’t be subject or predicate.

Representation of literals = Representation of URI

?S ?P ?O
limit 10


PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name
?person a foaf:Person.
?person foaf:name ?name

Note: It will show the name of from the DBpedia database. Output can be like this;




Akram is the name of the person and en indicates that Akram name is a word of English languages.

Example 2:

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name ?age
?person a foaf:Person;
foaf:name ?name.
OPTIONAL {?person foaf:age ?age}


Fazal Rehman Shamil
Welcome to all friends. The reason for our success is only your love for T4Tutorials. Our team is always available to answer your queries regarding any kind of confusions or discussion regarding your study and career matters. For discussion with us please join our facebook group "T4Tutorials.com". The link of the group is mentioned below. Thanks and love to all for connecting with us. We are nothing without you. Love you all.....