I have one table (FCT_POPULATION) with the following structure, representing a quantity of a range over the years for a single city. So, in the same year, I have two quantities, varying according to a range (ids 1 or 2):
CITY_ID | YEAR | RANGE_ID | QTY
-------------------------------
1100015 | 2021 | 1 | 134
1100015 | 2021 | 2 | 221
1100015 | 2022 | 1 | 158
1100015 | 2022 | 2 | 243
Since they are multiple measurements of the same city over the years, I would like to create an RDF structure like this, with a list of blank nodes representing the tuple (year, range, quantity) for each city:
<http://localhost:2020/resource/populacao/1100015/2021> a db:Population ;
db:indicator
[ :year 2021, :range 1, :quantity 134] ;
db:indicator
[ :year 2021, :range 2, :quantity 221] .
My mapping file is like this:
# Table FCT_POPULATION
map:Population a d2rq:ClassMap;
d2rq:dataStorage map:database;
d2rq:uriPattern "population/@@FCT_POPULATION.CITY_ID@@/@@FCT_POPULATION.YEAR@@";
d2rq:class :Population;
map:BN_Range_Year_QTY a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:Population;
d2rq:property :indicator;
d2rq:refersToClassMap map:Range_Year_QTY;
.
map:Range_Year_QTY a d2rq:ClassMap;
d2rq:dataStorage map:database; #database connection is ok.
d2rq:bNodeIdColumns "FCT_POPULATION.YEAR,FCT_POPULATION.RANGE_ID,FCT_POPULATION.QTY";
.
map:quantity a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:Range_Year_QTY ;
d2rq:property :quantity;
d2rq:column "FCT_POPULATION.QTY";
.
map:ano a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:Range_Year_QTY ;
d2rq:property :year;
d2rq:column "FCT_POPULATION.YEAR";
.
map:faixa a d2rq:PropertyBridge;
d2rq:belongsToClassMap map:Range_Year_QTY ;
d2rq:property :range;
d2rq:column "FCT_POPULATION.RANGE_ID";
.
It parses ok, but when I try to resolve a specific URI using "http://localhost:2020/data/population/1100015/2014" the following is returned with "blank" blank nodes:
<http://localhost:2020/resource/populacao/1100015/2014>
a db:Population ;
db:indicator
[] ;
db:indicator
[] ;
Any suggestions?
I am using d2rq v0.8.1 and PostgreSQL 14.2(x64) Windows 8.1, command line: d2r-server mapping.ttl