Saeed Ahmad
Saeed Ahmad

Reputation: 41

How to create an individual of a specific class from SPARQL query using Fuseki?

I am using insert data query to create an individual in this way

PREFIX d: <http://www.owl-ontologies.com/hecproject.owl#> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
INSERT Data
{
d:new2 d:hasUniversityName "Namal" .
d:University a rdfs:Class .
}

I am assuming that d:University is telling the query that created individual new2 is of type University class. When I execute the query it works fine and inserts a record in the dataset and when I execute a general query like this

SELECT ?subject ?predicate ?object
WHERE {
  ?subject ?predicate ?object
}

then individual is created but when i try to find all individuals of class University i do not find it like that was not created with class University?

Upvotes: 0

Views: 1017

Answers (1)

UninformedUser
UninformedUser

Reputation: 8465

You're not assigning the individual d:new2 to the class d:University in your INSERT query. All your query does it to add exactly the two triples

d:new2 d:hasUniversityName "Namal" .
d:University a rdfs:Class .

nothing more, nothing less.

Indeed it's up to you to the triple

d:new2 rdf:type d:University .

that assigns d:new2 to class d:University:

PREFIX d: <http://www.owl-ontologies.com/hecproject.owl#> 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
INSERT Data {
 d:new2 d:hasUniversityName "Namal" .
 d:new2 rdf:type d:University .
 d:University a rdfs:Class .
}

Upvotes: 1

Related Questions