Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping SQL with BlankNode class in Ontology #1

Open
MarcyRouge opened this issue Jan 28, 2021 · 0 comments
Open

Mapping SQL with BlankNode class in Ontology #1

MarcyRouge opened this issue Jan 28, 2021 · 0 comments

Comments

@MarcyRouge
Copy link

Hello,
I am sorry to send you directly this problem. I have seen that the d2rq gihub has been archived and it is read-only.
has it been stopped?
Anyway, I still hope you can reply to my message.
Thanks in advance
Marcela

I would like to have some advice in resolving a problem with a blank node class.

I am trying to map a blank node in my ontology to a SQL database and I haven’t been able to find the right format for the uri in the creation of the mapping class.

The example below illustrates the problem I am facing with a more complex ontology. I hope it can help as an example to understand the problem and helping solving it.
Let’s say I have an ontology of people that have their name and associated to them there is an address composed of the name of the street and the postal code.
In this case, the class “address” would be as a blank node.

You can find below: the ontology, the Sql tables in the data base and the corresponding mapping where I have different options for my problem:

Ontology

A person hasAddress address

Address hasStreet street
Address hasPostalCode PostalCode

Table in the SQL data base

dbo_Person
Name | Id

Dbo_Street
Name | Id

Dbo_PostalCode
PosteCode | Id

dbo_Person_Address
PersonID | StreetID | PostalCodeID

MAPPING

Table dbo_Address

Class Address - This table does not exist in the database, but it is created in the ontology which is a blankNode

map: dbo_Address a d2rq:ClassMap;
d2rq:class OntoPeople: Address;
d2rq:dataStorage map:database;

Option 1 :
d2rq:bNodeIdColumns "dbo.Person_Address.PersonId";
d2rq:bNodeIdColumns "Person_Address.PersonId";
Response: It does not work. NO results when sending the query

Option 2:

d2rq:uriSqlExpression
"CONCAT('http://www.semanticweb.org/ontologies/PeopleOntology#', dbo.Person.Id)";
Response : The concatenation does not work : (Incorrect syntax near ‘|’ : SELECT DISTINCT ……)

Option 3:
d2rq:uriPattern "'http://www.semanticweb.org/ontologies/PeopleOntology##@@dbo.Person.Id@@";

Response: It does not work : (com.microsoft.sqlserver.jdbc.SQLServerException: Conversion failed when converting the nvarchar value 'Pierre_Dupont' to data type int)

Option 4:
d2rq:uriPattern "'http://www.semanticweb.org/ontologies/PeopleOntology##@@dbo.Person.Name@@";
.
Response: It is the only way it works. However, I would like to set a unique identifier Id. For instance, a concatenation of the three Id’s : BlankNode_PersonID + StreetID + PostalCodeID

#Property of Class Address: has Address

map: hasAddress _PropertyBridge a d2rq:PropertyBridge;
d2rq:refersToClassMap map:dbo_Address;
d2rq:belongsToClassMap map:dbo_Person;
d2rq:property OntoPeople: hasAddress;
d2rq:join "dbo.Person_Address.PersonId => dbo.Person.Id";
d2rq:join "dbo.Person_Address.StreetId => dbo.Street.Id";
d2rq:join "dbo.Person_Address.PostalCodeId => dbo.PostalCode.Id";
.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant