I was wondering how I could model the following with r2rml:
Person -> has an address --> Blank Node [ Street Name, Postal Code, City ]
I'm note sure how I can add street name, postal code and city to the blank node within the rr:objectMap
(Additional question: Is a rr:class
mandatory for a rr:BlankNode
?)
Any suggestions? :)
<#Person>
rr:logicalTable [ rr:tableName "PERSON" ];
rr:subjectMap [
rr:template "http://ex.com/data/PersonClass/{ID}";
rr:class ex:PersonClass;
];
rr:preciateObjectMap [
rr:predicate ex:hasAddress;
rr:objectMap [
rr:termType rr:BlankNode;
## How/where can a add the street name, postal code, city? ##
];
].
Should be not too difficult. First you take the R2RML mapping you have created and create a blank node for the address. Give it a unique name by using a template, but do not give it an IRI so it is interpreted as a blank node.
<#Person>
rr:logicalTable [ rr:tableName "PERSON" ];
rr:subjectMap [
rr:template "http://ex.com/data/PersonClass/{ID}";
rr:class ex:PersonClass;
];
rr:preciateObjectMap [
rr:predicate ex:hasAddress;
rr:objectMap [
rr:template "BlankAddressNode{ADDRESSID}";
rr:termType rr:BlankNode;
];
].
Note: ADDRESSID in table PERSON is considered a foreign to the primary key of ADDRESS table.
Next you create the blank node with rdf:type and everything else.
<#Address>
rr:logicalTable [ rr:tableName "ADDRESS" ];
rr:subjectMap [
rr:template "BlankAddressNode{ID}";
rr:termType rr:BlankNode;
rr:class ex:AddressClass;
];
rr:predicateObjectMap [
rr:predicate ex:street;
rr:objectMap [ rr:column "Street"]
];
.
Note: ID is primary key of ADDRESS table.
You can do this with a join too... but I think from a tutorial point of view this is clearer.