I have a trouble with right construction of SPARQl query to D2RQ mapping-file.

I have a table in my db schema:


id integer NOT NULL,

argument1 character varying,

relation character varying,

argument2 character varying,

confidence double precision,



And there is only one row:

insert into fact values(1,'conributor','town','Berlin',0.67,4)

And I've generated a mapping between my schema and RDF model via mapping_generation command in D2RQ and get the following .ttl file:

@prefix map: <#> .

@prefix db: <> .

@prefix vocab: <vocab/> .

@prefix rdf: < http://www.w3.org/1999/02/22-rdf-syntax-ns# > .

@prefix rdfs: < http://www.w3.org/2000/01/rdf-schema# > .

@prefix xsd: < http://www.w3.org/2001/XMLSchema# > .

@prefix d2rq: < http://www.wiwiss.fu-berlin.de/suhl/bizer/D2RQ/0.1# > .

@prefix jdbc: < http://d2rq.org/terms/jdbc/ > .

map:database a d2rq:Database;

d2rq:jdbcDriver "org.postgresql.Driver";

d2rq:jdbcDSN "jdbc:postgresql://localhost:5432/postgres";

d2rq:username "postgres";

d2rq:password "password";

map:fact a d2rq:ClassMap;

d2rq:dataStorage map:database;

d2rq:uriPattern "fact/@@fact.id@@";

d2rq:class vocab:fact;

d2rq:classDefinitionLabel "fact";

map:fact__label a d2rq:PropertyBridge;

d2rq:belongsToClassMap map:fact;

d2rq:property rdfs:label;

d2rq:pattern "fact #@@fact.id@@";

map:fact_id a d2rq:PropertyBridge;

d2rq:belongsToClassMap map:fact;

d2rq:property vocab:fact_id;

d2rq:propertyDefinitionLabel "fact id";

d2rq:column "fact.id";

d2rq:datatype xsd:integer;

map:fact_argument1 a d2rq:PropertyBridge;

d2rq:belongsToClassMap map:fact;

d2rq:property vocab:fact_argument1;

d2rq:propertyDefinitionLabel "fact argument1";

d2rq:column "fact.argument1";

map:fact_relation a d2rq:PropertyBridge;

d2rq:belongsToClassMap map:fact;

d2rq:property vocab:fact_relation;

d2rq:propertyDefinitionLabel "fact relation";

d2rq:column "fact.relation";

map:fact_argument2 a d2rq:PropertyBridge;

d2rq:belongsToClassMap map:fact;

d2rq:property vocab:fact_argument2;

d2rq:propertyDefinitionLabel "fact argument2";

d2rq:column "fact.argument2";

map:fact_confidence a d2rq:PropertyBridge;

d2rq:belongsToClassMap map:fact;

d2rq:property vocab:fact_confidence;

d2rq:propertyDefinitionLabel "fact confidence";

d2rq:column "fact.confidence";

d2rq:datatype xsd:double;

My problem is that I don't know how to correctly write sparql query to this model.

How shoud sparql query look like for the following request: get relation1 where relation2 = 'Berlin'

Query, that I constructed, returns empty result:

PREFIX vocab: <vocab/>
SELECT ?name WHERE { ?id vocab: fact_argument2 "Berlin" . ?id vocab:fact _argument1 ?name . }

asked 01 Feb '13, 07:25

salamandra's gravatar image

accept rate: 0%

edited 01 Feb '13, 08:22

I guess I found the reason. I don't know why but it doesn,t return bindings for variables with postgreSQL type character varying. Any ideas why and how can it be corrected?

The second problem is that Jena doesn't what to return answer for any query over d2rq model. But if I run the same query from command line using d2r-query command, it returns correct answer (but again only if it doesn't have character varying type). How can I deal with it?

(01 Feb '13, 11:28) salamandra salamandra's gravatar image
Be the first one to answer this question!
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 01 Feb '13, 07:25

question was seen: 1,047 times

last updated: 01 Feb '13, 11:28