Fwd: Mapping questions

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Fwd: Mapping questions

giulianimartini
Hi,

I have some doubts about ontop mapping and what's the better way to map my source.
If someone already worked with ontop, please, help me.

An example of my DB schema is presented below with two tables:

1) identificacaoEmigrante table:






2) localidade table:







Here more information about the fields:

1)

`identificacaoEmigrante` (
  `idEmigrante` int(11) NOT NULL,
  `nome` varchar(64) NOT NULL,
  `dtNasc` date NOT NULL,
  `idConj` varchar(10) ,
  `nomeConj` varchar(64) ,
  `idFiliacao` int(11) NOT NULL,
  `idNaturalidade` int(11) NOT NULL,
  PRIMARY KEY (`idEmigrante`),
  KEY `idFiliacao` (`idFiliacao`),
  KEY `idNaturalidade` (`idNaturalidade`),
  CONSTRAINT `identificacaoemigrante_ibfk_1` FOREIGN KEY (`idFiliacao`) REFERENCES `Filiacao` (`idFiliacao`),
  CONSTRAINT `identificacaoemigrante_ibfk_2` FOREIGN KEY (`idNaturalidade`) REFERENCES `Localidade` (`idLocalidade`)
)

2)

`localidade` (
  `idLocalidade` int(11) NOT NULL AUTO_INCREMENT,
  `freguesia` varchar(64) NOT NULL,
  `concelho` varchar(64) NOT NULL,
  `distrito` varchar(64) NOT NULL,
  PRIMARY KEY (`idLocalidade`)
)

An example of my Ontology schema (CIDOC-CRM ontology for museums) detailing the DB schema is presented below:















So, I want the identificacaoEmigrante table, which describes an emigrant, i.e., a Person, to be related to the E21 Person concept.
Similarly, the localidade table describes places, so it should be related to the E53 Place concept.

At this point arises the first question:
1) Should I map the emigrant (identificacaoEmigrante) as E21 Person and the places (E53 Place) separately?
Ex:
    mappingID: emigrant
    Source: SELECT idEmigrante, nome FROM identificacaoEmigrante
    Target: {idEmigrante} a :E21_Person ; :P131_is_identified_by {nome} . {nome} a :E82:Actor_Appellation .

    mappingID: places
    Source: SELECT freguesia, concelho, distrito FROM localidade, identificacaoEmigrante WHERE identificacaoEmigrante.idNaturalidade = localidade.idLocalidade
    Target: {freguesia} a :E53_Place ; :P89_falls_within {concelho} . {concelho} a :E53_Place ; :P89_falls_within {distrito} . {distrito} a :E53_Place .

OR
2) Should I map the places separately?

    mappingID: freguesia
    Source: SELECT freguesia FROM localidade, identificacaoEmigrante WHERE identificacaoEmigrante.idNaturalidade = localidade.idLocalidade
    Target: {freguesia} a :E53_Place ; :P89_falls_within :E53_Place .

Repeating the same to concelho and distrito.

Here arises the second doubt, for example: how can I query (SPARQL) a list of all freguesias (parish), concelhos (council) and distritos (district)?

SELECT ?f ?c ?d
WHERE { ?f a :E53_Place ; :P89_falls_within ?c .
                ?c a :E53_Place ; :P89_falls_within ?d .
                ?d a :E53_Place . }

Notice that exist another tables in my database describing persons (not only identificacaoEmigrante), so, I didn't want to map identificacaoEmigrante just as {idEmigrante} a :E21_Person like this example. The identificacaoEmigrante mapping should include another concept (E9 Move) of my ontology that describes the emigration movement event. Thus, what identifies an emigrant is already having participated in an emigration movement.

Sorry for the very extensive question, but I wanted to detail as much as possible :)

Thanks in advance.

--
You received this message because you are subscribed to a topic in the Google Groups "ontop4obda" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ontop4obda/qPjWyyPQ17k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--
Ricardo G. Martini, MsC.
---------------------------------------------------------------------------
Doutorando em Informática
Programa Doutoral em Informática (PDInf)
Centro Algoritmi
Universidade do Minho (UMinho) - Braga, Portugal

Mestre em Computação - Universidade Federal de Santa Maria (UFSM)
Santa Maria, RS, Brasil
Lattes CV: http://lattes.cnpq.br/8710772034085679
---------------------------------------------------------------------------

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Mapping questions

Josef Hardi
Hi Ricardo,

let me try to answer your questions. 

A) For your first question, the answer is to separate them. AFAIK -ontop- mappings must have only 1 subject map. What I mean by subject map is the rdf:type or the ‘a’ class definition. So in your first example, you should not have the definition of :E21_Person and :E82_Actor_Appellation in the same mapping. The rest of your ‘Target’ schema is the predicate-object map which can be zero or many. These maps are the data or object properties that belong to the initial subject class.

One thing to note is that you should put a prefix after your column-variable assignment, especially when you are working with class and object property assertions.

For example, the right syntax to write is:

Example 1:
:{idEmigrante} a :E21_Person ; :P131_is_identified_by {nome} 

Example 2:
:{freguesia} a :E53_Place ; :P89_falls_within :{concelho}


B) Now here comes the tricky part of developing the mappings (related to your second and third question).

Before we get into your SPARQL query test, I suggest you to rewrite the places mappings as follow:

MappingID: Places
Source: SELECT idLocalidade, freguensa FROM localidade
Target: :{idLocalidade} a :E53_Place ; :P89_falls_within :freguensia/{freguensa} .

MappingID: Parish
Source: SELECT freguensa, concelho FROM localidade
Target: :freguensia/{frequensa} a :E53_Place ; :P89_falls_within :concelho/{concelho} .

MappingID: Council
Source: SELECT concelho, distrito FROM localidade
Target: :concelho/{concelho} a :E53_Place ; :P89_falls_within :distrito/{distrito} .

MappingID: District
Source: SELECT district FROM localized
Target: :distrito/{distrito} a :E53_Place .

Testing queries:

SELECT DISTINCT ?x WHERE {
   ?x a :E53_Place . # Will show all places IRI defined in the mappings, i.e., Places, Parish, Council, District
}

SELECT DISTINCT ?x ?y WHERE {
   ?x :P89_falls_within ?y . # Will show the city administration hierarchy
}

(Notice the strategy that I used to have the IRI template unique and more informative for each Localidade, Freguensa, Concelho, and Distrito; and also notice I didn’t use JOIN table in the source query. I think the best practice of creating OBDA model (i.e., the mappings) is to avoid join table expressions and let the reasoner formulates the joining when it translates SPARQL queries to SQL.


C) If you have another information about the :E21_Person class then just create a new one. So for example, you have that information in another table, say, table X

MappingID: Person in Table X
Source: SELECT personID FROM X
Target: :{personID} a :E21_Person .

The consequence is that when you query SELECT ?x WHERE { ?x a :E21_Person . } the -ontop- reasoner will collect the answer from both tables. But note that in case you know table X doesn’t give you new information about Person (for example, the data is actually just a foreign key from the “master table" identificacaoEmigrante) then I suggest you don’t need to create a new mapping. Creating a new class definition mapping (or subject map) should only be done when you have different table sources that would give you different (or new) information. It will make your model less complicated.

Hope my answers can help. They are quite long and hopefully you won’t get lost :)

Cheers!

/Josef

PS. There might be errors if you just copy-and-paste everything since I haven’t tested these mappings. Just an illustration from what I understand of the system.


On Oct 14, 2015, at 2:17 AM, Ricardo G. Martini <[hidden email]> wrote:

Hi,

I have some doubts about ontop mapping and what's the better way to map my source.
If someone already worked with ontop, please, help me.

An example of my DB schema is presented below with two tables:

1) identificacaoEmigrante table:






2) localidade table:







Here more information about the fields:

1)

`identificacaoEmigrante` (
  `idEmigrante` int(11) NOT NULL,
  `nome` varchar(64) NOT NULL,
  `dtNasc` date NOT NULL,
  `idConj` varchar(10) ,
  `nomeConj` varchar(64) ,
  `idFiliacao` int(11) NOT NULL,
  `idNaturalidade` int(11) NOT NULL,
  PRIMARY KEY (`idEmigrante`),
  KEY `idFiliacao` (`idFiliacao`),
  KEY `idNaturalidade` (`idNaturalidade`),
  CONSTRAINT `identificacaoemigrante_ibfk_1` FOREIGN KEY (`idFiliacao`) REFERENCES `Filiacao` (`idFiliacao`),
  CONSTRAINT `identificacaoemigrante_ibfk_2` FOREIGN KEY (`idNaturalidade`) REFERENCES `Localidade` (`idLocalidade`)
)

2)

`localidade` (
  `idLocalidade` int(11) NOT NULL AUTO_INCREMENT,
  `freguesia` varchar(64) NOT NULL,
  `concelho` varchar(64) NOT NULL,
  `distrito` varchar(64) NOT NULL,
  PRIMARY KEY (`idLocalidade`)
)

An example of my Ontology schema (CIDOC-CRM ontology for museums) detailing the DB schema is presented below:















So, I want the identificacaoEmigrante table, which describes an emigrant, i.e., a Person, to be related to the E21 Person concept.
Similarly, the localidade table describes places, so it should be related to the E53 Place concept.

At this point arises the first question:
1) Should I map the emigrant (identificacaoEmigrante) as E21 Person and the places (E53 Place) separately?
Ex:
    mappingID: emigrant
    Source: SELECT idEmigrante, nome FROM identificacaoEmigrante
    Target: {idEmigrante} a :E21_Person ; :P131_is_identified_by {nome} . {nome} a :E82:Actor_Appellation .

    mappingID: places
    Source: SELECT freguesia, concelho, distrito FROM localidade, identificacaoEmigrante WHERE identificacaoEmigrante.idNaturalidade = localidade.idLocalidade
    Target: {freguesia} a :E53_Place ; :P89_falls_within {concelho} . {concelho} a :E53_Place ; :P89_falls_within {distrito} . {distrito} a :E53_Place .

OR
2) Should I map the places separately?

    mappingID: freguesia
    Source: SELECT freguesia FROM localidade, identificacaoEmigrante WHERE identificacaoEmigrante.idNaturalidade = localidade.idLocalidade
    Target: {freguesia} a :E53_Place ; :P89_falls_within :E53_Place .

Repeating the same to concelho and distrito.

Here arises the second doubt, for example: how can I query (SPARQL) a list of all freguesias (parish), concelhos (council) and distritos (district)?

SELECT ?f ?c ?d
WHERE { ?f a :E53_Place ; :P89_falls_within ?c .
                ?c a :E53_Place ; :P89_falls_within ?d .
                ?d a :E53_Place . }

Notice that exist another tables in my database describing persons (not only identificacaoEmigrante), so, I didn't want to map identificacaoEmigrante just as {idEmigrante} a :E21_Person like this example. The identificacaoEmigrante mapping should include another concept (E9 Move) of my ontology that describes the emigration movement event. Thus, what identifies an emigrant is already having participated in an emigration movement.

Sorry for the very extensive question, but I wanted to detail as much as possible :)

Thanks in advance.

--
You received this message because you are subscribed to a topic in the Google Groups "ontop4obda" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ontop4obda/qPjWyyPQ17k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--
Ricardo G. Martini, MsC.
---------------------------------------------------------------------------
Doutorando em Informática
Programa Doutoral em Informática (PDInf)
Centro Algoritmi
Universidade do Minho (UMinho) - Braga, Portugal

Mestre em Computação - Universidade Federal de Santa Maria (UFSM)
Santa Maria, RS, Brasil
Lattes CV: http://lattes.cnpq.br/8710772034085679
---------------------------------------------------------------------------
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Mapping questions

giulianimartini
Hi Josef,

Thank you very much for your help!

I will consider each answer and try the mapping in the correct way :D

Thanks,

On Wed, Oct 14, 2015 at 6:57 PM, Josef Hardi <[hidden email]> wrote:
Hi Ricardo,

let me try to answer your questions. 

A) For your first question, the answer is to separate them. AFAIK -ontop- mappings must have only 1 subject map. What I mean by subject map is the rdf:type or the ‘a’ class definition. So in your first example, you should not have the definition of :E21_Person and :E82_Actor_Appellation in the same mapping. The rest of your ‘Target’ schema is the predicate-object map which can be zero or many. These maps are the data or object properties that belong to the initial subject class.

One thing to note is that you should put a prefix after your column-variable assignment, especially when you are working with class and object property assertions.

For example, the right syntax to write is:

Example 1:
:{idEmigrante} a :E21_Person ; :P131_is_identified_by {nome} 

Example 2:
:{freguesia} a :E53_Place ; :P89_falls_within :{concelho}


B) Now here comes the tricky part of developing the mappings (related to your second and third question).

Before we get into your SPARQL query test, I suggest you to rewrite the places mappings as follow:

MappingID: Places
Source: SELECT idLocalidade, freguensa FROM localidade
Target: :{idLocalidade} a :E53_Place ; :P89_falls_within :freguensia/{freguensa} .

MappingID: Parish
Source: SELECT freguensa, concelho FROM localidade
Target: :freguensia/{frequensa} a :E53_Place ; :P89_falls_within :concelho/{concelho} .

MappingID: Council
Source: SELECT concelho, distrito FROM localidade
Target: :concelho/{concelho} a :E53_Place ; :P89_falls_within :distrito/{distrito} .

MappingID: District
Source: SELECT district FROM localized
Target: :distrito/{distrito} a :E53_Place .

Testing queries:

SELECT DISTINCT ?x WHERE {
   ?x a :E53_Place . # Will show all places IRI defined in the mappings, i.e., Places, Parish, Council, District
}

SELECT DISTINCT ?x ?y WHERE {
   ?x :P89_falls_within ?y . # Will show the city administration hierarchy
}

(Notice the strategy that I used to have the IRI template unique and more informative for each Localidade, Freguensa, Concelho, and Distrito; and also notice I didn’t use JOIN table in the source query. I think the best practice of creating OBDA model (i.e., the mappings) is to avoid join table expressions and let the reasoner formulates the joining when it translates SPARQL queries to SQL.


C) If you have another information about the :E21_Person class then just create a new one. So for example, you have that information in another table, say, table X

MappingID: Person in Table X
Source: SELECT personID FROM X
Target: :{personID} a :E21_Person .

The consequence is that when you query SELECT ?x WHERE { ?x a :E21_Person . } the -ontop- reasoner will collect the answer from both tables. But note that in case you know table X doesn’t give you new information about Person (for example, the data is actually just a foreign key from the “master table" identificacaoEmigrante) then I suggest you don’t need to create a new mapping. Creating a new class definition mapping (or subject map) should only be done when you have different table sources that would give you different (or new) information. It will make your model less complicated.

Hope my answers can help. They are quite long and hopefully you won’t get lost :)

Cheers!

/Josef

PS. There might be errors if you just copy-and-paste everything since I haven’t tested these mappings. Just an illustration from what I understand of the system.


On Oct 14, 2015, at 2:17 AM, Ricardo G. Martini <[hidden email]> wrote:

Hi,

I have some doubts about ontop mapping and what's the better way to map my source.
If someone already worked with ontop, please, help me.

An example of my DB schema is presented below with two tables:

1) identificacaoEmigrante table:






2) localidade table:







Here more information about the fields:

1)

`identificacaoEmigrante` (
  `idEmigrante` int(11) NOT NULL,
  `nome` varchar(64) NOT NULL,
  `dtNasc` date NOT NULL,
  `idConj` varchar(10) ,
  `nomeConj` varchar(64) ,
  `idFiliacao` int(11) NOT NULL,
  `idNaturalidade` int(11) NOT NULL,
  PRIMARY KEY (`idEmigrante`),
  KEY `idFiliacao` (`idFiliacao`),
  KEY `idNaturalidade` (`idNaturalidade`),
  CONSTRAINT `identificacaoemigrante_ibfk_1` FOREIGN KEY (`idFiliacao`) REFERENCES `Filiacao` (`idFiliacao`),
  CONSTRAINT `identificacaoemigrante_ibfk_2` FOREIGN KEY (`idNaturalidade`) REFERENCES `Localidade` (`idLocalidade`)
)

2)

`localidade` (
  `idLocalidade` int(11) NOT NULL AUTO_INCREMENT,
  `freguesia` varchar(64) NOT NULL,
  `concelho` varchar(64) NOT NULL,
  `distrito` varchar(64) NOT NULL,
  PRIMARY KEY (`idLocalidade`)
)

An example of my Ontology schema (CIDOC-CRM ontology for museums) detailing the DB schema is presented below:















So, I want the identificacaoEmigrante table, which describes an emigrant, i.e., a Person, to be related to the E21 Person concept.
Similarly, the localidade table describes places, so it should be related to the E53 Place concept.

At this point arises the first question:
1) Should I map the emigrant (identificacaoEmigrante) as E21 Person and the places (E53 Place) separately?
Ex:
    mappingID: emigrant
    Source: SELECT idEmigrante, nome FROM identificacaoEmigrante
    Target: {idEmigrante} a :E21_Person ; :P131_is_identified_by {nome} . {nome} a :E82:Actor_Appellation .

    mappingID: places
    Source: SELECT freguesia, concelho, distrito FROM localidade, identificacaoEmigrante WHERE identificacaoEmigrante.idNaturalidade = localidade.idLocalidade
    Target: {freguesia} a :E53_Place ; :P89_falls_within {concelho} . {concelho} a :E53_Place ; :P89_falls_within {distrito} . {distrito} a :E53_Place .

OR
2) Should I map the places separately?

    mappingID: freguesia
    Source: SELECT freguesia FROM localidade, identificacaoEmigrante WHERE identificacaoEmigrante.idNaturalidade = localidade.idLocalidade
    Target: {freguesia} a :E53_Place ; :P89_falls_within :E53_Place .

Repeating the same to concelho and distrito.

Here arises the second doubt, for example: how can I query (SPARQL) a list of all freguesias (parish), concelhos (council) and distritos (district)?

SELECT ?f ?c ?d
WHERE { ?f a :E53_Place ; :P89_falls_within ?c .
                ?c a :E53_Place ; :P89_falls_within ?d .
                ?d a :E53_Place . }

Notice that exist another tables in my database describing persons (not only identificacaoEmigrante), so, I didn't want to map identificacaoEmigrante just as {idEmigrante} a :E21_Person like this example. The identificacaoEmigrante mapping should include another concept (E9 Move) of my ontology that describes the emigration movement event. Thus, what identifies an emigrant is already having participated in an emigration movement.

Sorry for the very extensive question, but I wanted to detail as much as possible :)

Thanks in advance.

--
You received this message because you are subscribed to a topic in the Google Groups "ontop4obda" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ontop4obda/qPjWyyPQ17k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--
Ricardo G. Martini, MsC.
---------------------------------------------------------------------------
Doutorando em Informática
Programa Doutoral em Informática (PDInf)
Centro Algoritmi
Universidade do Minho (UMinho) - Braga, Portugal

Mestre em Computação - Universidade Federal de Santa Maria (UFSM)
Santa Maria, RS, Brasil
Lattes CV: http://lattes.cnpq.br/8710772034085679
---------------------------------------------------------------------------
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user




--
Ricardo G. Martini, MsC.
---------------------------------------------------------------------------
Doutorando em Informática
Programa Doutoral em Informática (PDInf)
Centro Algoritmi
Universidade do Minho (UMinho) - Braga, Portugal

Mestre em Computação - Universidade Federal de Santa Maria (UFSM)
Santa Maria, RS, Brasil
Lattes CV: http://lattes.cnpq.br/8710772034085679
---------------------------------------------------------------------------

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Mapping questions

giulianimartini
In reply to this post by Josef Hardi
Hi,

I have another doubt about my mappings with ontop (OBDA) and CIDOC-CRM.

In identificacaoEmigrante table there is a field dtNasc, which represent a birthdate.

I would like to map this as follows:

mappingID    birthdate emigrant
target            :{dtNasc} a :E67_Birth ; :P4_has_time-span {dtNasc} .
source          SELECT dtNasc FROM identificacaoEmigrante

mappingID    date
target            :{dtNasc} a :E52_Time-Span ; :P78_is_identified_by {dtNasc} .
source          SELECT dtNasc FROM identificacaoEmigrante

This should reflect this schema:


But my doubt is: should I create two mappings with the same source?
Notice that there is a E21 Person concept related to E67 Birth that should be mapped too. I can't relate E21 Person directly to E52 Time-Span or E50 Date.

Thanks in advance,


On Wed, Oct 14, 2015 at 6:57 PM, Josef Hardi <[hidden email]> wrote:
Hi Ricardo,

let me try to answer your questions. 

A) For your first question, the answer is to separate them. AFAIK -ontop- mappings must have only 1 subject map. What I mean by subject map is the rdf:type or the ‘a’ class definition. So in your first example, you should not have the definition of :E21_Person and :E82_Actor_Appellation in the same mapping. The rest of your ‘Target’ schema is the predicate-object map which can be zero or many. These maps are the data or object properties that belong to the initial subject class.

One thing to note is that you should put a prefix after your column-variable assignment, especially when you are working with class and object property assertions.

For example, the right syntax to write is:

Example 1:
:{idEmigrante} a :E21_Person ; :P131_is_identified_by {nome} 

Example 2:
:{freguesia} a :E53_Place ; :P89_falls_within :{concelho}


B) Now here comes the tricky part of developing the mappings (related to your second and third question).

Before we get into your SPARQL query test, I suggest you to rewrite the places mappings as follow:

MappingID: Places
Source: SELECT idLocalidade, freguensa FROM localidade
Target: :{idLocalidade} a :E53_Place ; :P89_falls_within :freguensia/{freguensa} .

MappingID: Parish
Source: SELECT freguensa, concelho FROM localidade
Target: :freguensia/{frequensa} a :E53_Place ; :P89_falls_within :concelho/{concelho} .

MappingID: Council
Source: SELECT concelho, distrito FROM localidade
Target: :concelho/{concelho} a :E53_Place ; :P89_falls_within :distrito/{distrito} .

MappingID: District
Source: SELECT district FROM localized
Target: :distrito/{distrito} a :E53_Place .

Testing queries:

SELECT DISTINCT ?x WHERE {
   ?x a :E53_Place . # Will show all places IRI defined in the mappings, i.e., Places, Parish, Council, District
}

SELECT DISTINCT ?x ?y WHERE {
   ?x :P89_falls_within ?y . # Will show the city administration hierarchy
}

(Notice the strategy that I used to have the IRI template unique and more informative for each Localidade, Freguensa, Concelho, and Distrito; and also notice I didn’t use JOIN table in the source query. I think the best practice of creating OBDA model (i.e., the mappings) is to avoid join table expressions and let the reasoner formulates the joining when it translates SPARQL queries to SQL.


C) If you have another information about the :E21_Person class then just create a new one. So for example, you have that information in another table, say, table X

MappingID: Person in Table X
Source: SELECT personID FROM X
Target: :{personID} a :E21_Person .

The consequence is that when you query SELECT ?x WHERE { ?x a :E21_Person . } the -ontop- reasoner will collect the answer from both tables. But note that in case you know table X doesn’t give you new information about Person (for example, the data is actually just a foreign key from the “master table" identificacaoEmigrante) then I suggest you don’t need to create a new mapping. Creating a new class definition mapping (or subject map) should only be done when you have different table sources that would give you different (or new) information. It will make your model less complicated.

Hope my answers can help. They are quite long and hopefully you won’t get lost :)

Cheers!

/Josef

PS. There might be errors if you just copy-and-paste everything since I haven’t tested these mappings. Just an illustration from what I understand of the system.


On Oct 14, 2015, at 2:17 AM, Ricardo G. Martini <[hidden email]> wrote:

Hi,

I have some doubts about ontop mapping and what's the better way to map my source.
If someone already worked with ontop, please, help me.

An example of my DB schema is presented below with two tables:

1) identificacaoEmigrante table:






2) localidade table:







Here more information about the fields:

1)

`identificacaoEmigrante` (
  `idEmigrante` int(11) NOT NULL,
  `nome` varchar(64) NOT NULL,
  `dtNasc` date NOT NULL,
  `idConj` varchar(10) ,
  `nomeConj` varchar(64) ,
  `idFiliacao` int(11) NOT NULL,
  `idNaturalidade` int(11) NOT NULL,
  PRIMARY KEY (`idEmigrante`),
  KEY `idFiliacao` (`idFiliacao`),
  KEY `idNaturalidade` (`idNaturalidade`),
  CONSTRAINT `identificacaoemigrante_ibfk_1` FOREIGN KEY (`idFiliacao`) REFERENCES `Filiacao` (`idFiliacao`),
  CONSTRAINT `identificacaoemigrante_ibfk_2` FOREIGN KEY (`idNaturalidade`) REFERENCES `Localidade` (`idLocalidade`)
)

2)

`localidade` (
  `idLocalidade` int(11) NOT NULL AUTO_INCREMENT,
  `freguesia` varchar(64) NOT NULL,
  `concelho` varchar(64) NOT NULL,
  `distrito` varchar(64) NOT NULL,
  PRIMARY KEY (`idLocalidade`)
)

An example of my Ontology schema (CIDOC-CRM ontology for museums) detailing the DB schema is presented below:















So, I want the identificacaoEmigrante table, which describes an emigrant, i.e., a Person, to be related to the E21 Person concept.
Similarly, the localidade table describes places, so it should be related to the E53 Place concept.

At this point arises the first question:
1) Should I map the emigrant (identificacaoEmigrante) as E21 Person and the places (E53 Place) separately?
Ex:
    mappingID: emigrant
    Source: SELECT idEmigrante, nome FROM identificacaoEmigrante
    Target: {idEmigrante} a :E21_Person ; :P131_is_identified_by {nome} . {nome} a :E82:Actor_Appellation .

    mappingID: places
    Source: SELECT freguesia, concelho, distrito FROM localidade, identificacaoEmigrante WHERE identificacaoEmigrante.idNaturalidade = localidade.idLocalidade
    Target: {freguesia} a :E53_Place ; :P89_falls_within {concelho} . {concelho} a :E53_Place ; :P89_falls_within {distrito} . {distrito} a :E53_Place .

OR
2) Should I map the places separately?

    mappingID: freguesia
    Source: SELECT freguesia FROM localidade, identificacaoEmigrante WHERE identificacaoEmigrante.idNaturalidade = localidade.idLocalidade
    Target: {freguesia} a :E53_Place ; :P89_falls_within :E53_Place .

Repeating the same to concelho and distrito.

Here arises the second doubt, for example: how can I query (SPARQL) a list of all freguesias (parish), concelhos (council) and distritos (district)?

SELECT ?f ?c ?d
WHERE { ?f a :E53_Place ; :P89_falls_within ?c .
                ?c a :E53_Place ; :P89_falls_within ?d .
                ?d a :E53_Place . }

Notice that exist another tables in my database describing persons (not only identificacaoEmigrante), so, I didn't want to map identificacaoEmigrante just as {idEmigrante} a :E21_Person like this example. The identificacaoEmigrante mapping should include another concept (E9 Move) of my ontology that describes the emigration movement event. Thus, what identifies an emigrant is already having participated in an emigration movement.

Sorry for the very extensive question, but I wanted to detail as much as possible :)

Thanks in advance.

--
You received this message because you are subscribed to a topic in the Google Groups "ontop4obda" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ontop4obda/qPjWyyPQ17k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--
Ricardo G. Martini, MsC.
---------------------------------------------------------------------------
Doutorando em Informática
Programa Doutoral em Informática (PDInf)
Centro Algoritmi
Universidade do Minho (UMinho) - Braga, Portugal

Mestre em Computação - Universidade Federal de Santa Maria (UFSM)
Santa Maria, RS, Brasil
Lattes CV: http://lattes.cnpq.br/8710772034085679
---------------------------------------------------------------------------
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user




--
Ricardo G. Martini, MsC.
---------------------------------------------------------------------------
Doutorando em Informática
Programa Doutoral em Informática (PDInf)
Centro Algoritmi
Universidade do Minho (UMinho) - Braga, Portugal

Mestre em Computação - Universidade Federal de Santa Maria (UFSM)
Santa Maria, RS, Brasil
Lattes CV: http://lattes.cnpq.br/8710772034085679
---------------------------------------------------------------------------

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Reply | Threaded
Open this post in threaded view
|

Re: Mapping questions

giulianimartini
Hi,

just for thank you guys.

Now my mappings are correct and working.

For similar issues in the future, I solved my last question this way (2 mappings):

mappingId    Nascimento Emigrante
target            :nascimentoEmigrante#{idEmigrante} a :E67_Birth ; :P4_has_time-span :dataNascimentoEmigrante/{dtNasc} ; :P96_by_mother :Filiacao#{idFiliacao} ; :P97_from_father :Filiacao#{idFiliacao} ; :P98_brought_into_life :Emigrante#{idEmigrante} ; :P7_took_place_at :Naturalidade#{idNaturalidade} .
source          SELECT idEmigrante, dtNasc, idFiliacao, idNaturalidade FROM identificacaoEmigrante

mappingId    Data Nascimento Emigrante
target            :dataNascimentoEmigrante/{dtNasc} a :E52_Time-Span ; :P3_has_note {dtNasc} .
source          SELECT dtNasc FROM identificacaoEmigrante

That's the way that I chose to map the E67 Birth P4 has time-span E52 Time-Span.

Best Regards,

On Mon, Oct 26, 2015 at 7:14 PM, Ricardo G. Martini <[hidden email]> wrote:
Hi,

I have another doubt about my mappings with ontop (OBDA) and CIDOC-CRM.

In identificacaoEmigrante table there is a field dtNasc, which represent a birthdate.

I would like to map this as follows:

mappingID    birthdate emigrant
target            :{dtNasc} a :E67_Birth ; :P4_has_time-span {dtNasc} .
source          SELECT dtNasc FROM identificacaoEmigrante

mappingID    date
target            :{dtNasc} a :E52_Time-Span ; :P78_is_identified_by {dtNasc} .
source          SELECT dtNasc FROM identificacaoEmigrante

This should reflect this schema:


But my doubt is: should I create two mappings with the same source?
Notice that there is a E21 Person concept related to E67 Birth that should be mapped too. I can't relate E21 Person directly to E52 Time-Span or E50 Date.

Thanks in advance,


On Wed, Oct 14, 2015 at 6:57 PM, Josef Hardi <[hidden email]> wrote:
Hi Ricardo,

let me try to answer your questions. 

A) For your first question, the answer is to separate them. AFAIK -ontop- mappings must have only 1 subject map. What I mean by subject map is the rdf:type or the ‘a’ class definition. So in your first example, you should not have the definition of :E21_Person and :E82_Actor_Appellation in the same mapping. The rest of your ‘Target’ schema is the predicate-object map which can be zero or many. These maps are the data or object properties that belong to the initial subject class.

One thing to note is that you should put a prefix after your column-variable assignment, especially when you are working with class and object property assertions.

For example, the right syntax to write is:

Example 1:
:{idEmigrante} a :E21_Person ; :P131_is_identified_by {nome} 

Example 2:
:{freguesia} a :E53_Place ; :P89_falls_within :{concelho}


B) Now here comes the tricky part of developing the mappings (related to your second and third question).

Before we get into your SPARQL query test, I suggest you to rewrite the places mappings as follow:

MappingID: Places
Source: SELECT idLocalidade, freguensa FROM localidade
Target: :{idLocalidade} a :E53_Place ; :P89_falls_within :freguensia/{freguensa} .

MappingID: Parish
Source: SELECT freguensa, concelho FROM localidade
Target: :freguensia/{frequensa} a :E53_Place ; :P89_falls_within :concelho/{concelho} .

MappingID: Council
Source: SELECT concelho, distrito FROM localidade
Target: :concelho/{concelho} a :E53_Place ; :P89_falls_within :distrito/{distrito} .

MappingID: District
Source: SELECT district FROM localized
Target: :distrito/{distrito} a :E53_Place .

Testing queries:

SELECT DISTINCT ?x WHERE {
   ?x a :E53_Place . # Will show all places IRI defined in the mappings, i.e., Places, Parish, Council, District
}

SELECT DISTINCT ?x ?y WHERE {
   ?x :P89_falls_within ?y . # Will show the city administration hierarchy
}

(Notice the strategy that I used to have the IRI template unique and more informative for each Localidade, Freguensa, Concelho, and Distrito; and also notice I didn’t use JOIN table in the source query. I think the best practice of creating OBDA model (i.e., the mappings) is to avoid join table expressions and let the reasoner formulates the joining when it translates SPARQL queries to SQL.


C) If you have another information about the :E21_Person class then just create a new one. So for example, you have that information in another table, say, table X

MappingID: Person in Table X
Source: SELECT personID FROM X
Target: :{personID} a :E21_Person .

The consequence is that when you query SELECT ?x WHERE { ?x a :E21_Person . } the -ontop- reasoner will collect the answer from both tables. But note that in case you know table X doesn’t give you new information about Person (for example, the data is actually just a foreign key from the “master table" identificacaoEmigrante) then I suggest you don’t need to create a new mapping. Creating a new class definition mapping (or subject map) should only be done when you have different table sources that would give you different (or new) information. It will make your model less complicated.

Hope my answers can help. They are quite long and hopefully you won’t get lost :)

Cheers!

/Josef

PS. There might be errors if you just copy-and-paste everything since I haven’t tested these mappings. Just an illustration from what I understand of the system.


On Oct 14, 2015, at 2:17 AM, Ricardo G. Martini <[hidden email]> wrote:

Hi,

I have some doubts about ontop mapping and what's the better way to map my source.
If someone already worked with ontop, please, help me.

An example of my DB schema is presented below with two tables:

1) identificacaoEmigrante table:






2) localidade table:







Here more information about the fields:

1)

`identificacaoEmigrante` (
  `idEmigrante` int(11) NOT NULL,
  `nome` varchar(64) NOT NULL,
  `dtNasc` date NOT NULL,
  `idConj` varchar(10) ,
  `nomeConj` varchar(64) ,
  `idFiliacao` int(11) NOT NULL,
  `idNaturalidade` int(11) NOT NULL,
  PRIMARY KEY (`idEmigrante`),
  KEY `idFiliacao` (`idFiliacao`),
  KEY `idNaturalidade` (`idNaturalidade`),
  CONSTRAINT `identificacaoemigrante_ibfk_1` FOREIGN KEY (`idFiliacao`) REFERENCES `Filiacao` (`idFiliacao`),
  CONSTRAINT `identificacaoemigrante_ibfk_2` FOREIGN KEY (`idNaturalidade`) REFERENCES `Localidade` (`idLocalidade`)
)

2)

`localidade` (
  `idLocalidade` int(11) NOT NULL AUTO_INCREMENT,
  `freguesia` varchar(64) NOT NULL,
  `concelho` varchar(64) NOT NULL,
  `distrito` varchar(64) NOT NULL,
  PRIMARY KEY (`idLocalidade`)
)

An example of my Ontology schema (CIDOC-CRM ontology for museums) detailing the DB schema is presented below:















So, I want the identificacaoEmigrante table, which describes an emigrant, i.e., a Person, to be related to the E21 Person concept.
Similarly, the localidade table describes places, so it should be related to the E53 Place concept.

At this point arises the first question:
1) Should I map the emigrant (identificacaoEmigrante) as E21 Person and the places (E53 Place) separately?
Ex:
    mappingID: emigrant
    Source: SELECT idEmigrante, nome FROM identificacaoEmigrante
    Target: {idEmigrante} a :E21_Person ; :P131_is_identified_by {nome} . {nome} a :E82:Actor_Appellation .

    mappingID: places
    Source: SELECT freguesia, concelho, distrito FROM localidade, identificacaoEmigrante WHERE identificacaoEmigrante.idNaturalidade = localidade.idLocalidade
    Target: {freguesia} a :E53_Place ; :P89_falls_within {concelho} . {concelho} a :E53_Place ; :P89_falls_within {distrito} . {distrito} a :E53_Place .

OR
2) Should I map the places separately?

    mappingID: freguesia
    Source: SELECT freguesia FROM localidade, identificacaoEmigrante WHERE identificacaoEmigrante.idNaturalidade = localidade.idLocalidade
    Target: {freguesia} a :E53_Place ; :P89_falls_within :E53_Place .

Repeating the same to concelho and distrito.

Here arises the second doubt, for example: how can I query (SPARQL) a list of all freguesias (parish), concelhos (council) and distritos (district)?

SELECT ?f ?c ?d
WHERE { ?f a :E53_Place ; :P89_falls_within ?c .
                ?c a :E53_Place ; :P89_falls_within ?d .
                ?d a :E53_Place . }

Notice that exist another tables in my database describing persons (not only identificacaoEmigrante), so, I didn't want to map identificacaoEmigrante just as {idEmigrante} a :E21_Person like this example. The identificacaoEmigrante mapping should include another concept (E9 Move) of my ontology that describes the emigration movement event. Thus, what identifies an emigrant is already having participated in an emigration movement.

Sorry for the very extensive question, but I wanted to detail as much as possible :)

Thanks in advance.

--
You received this message because you are subscribed to a topic in the Google Groups "ontop4obda" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ontop4obda/qPjWyyPQ17k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--
Ricardo G. Martini, MsC.
---------------------------------------------------------------------------
Doutorando em Informática
Programa Doutoral em Informática (PDInf)
Centro Algoritmi
Universidade do Minho (UMinho) - Braga, Portugal

Mestre em Computação - Universidade Federal de Santa Maria (UFSM)
Santa Maria, RS, Brasil
Lattes CV: http://lattes.cnpq.br/8710772034085679
---------------------------------------------------------------------------
_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user


_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user




--
Ricardo G. Martini, MsC.
---------------------------------------------------------------------------
Doutorando em Informática
Programa Doutoral em Informática (PDInf)
Centro Algoritmi
Universidade do Minho (UMinho) - Braga, Portugal

Mestre em Computação - Universidade Federal de Santa Maria (UFSM)
Santa Maria, RS, Brasil
Lattes CV: http://lattes.cnpq.br/8710772034085679
---------------------------------------------------------------------------



--
Ricardo G. Martini, MsC.
---------------------------------------------------------------------------
Doutorando em Informática
Programa Doutoral em Informática (PDInf)
Centro Algoritmi
Universidade do Minho (UMinho) - Braga, Portugal

Mestre em Computação - Universidade Federal de Santa Maria (UFSM)
Santa Maria, RS, Brasil
Lattes CV: http://lattes.cnpq.br/8710772034085679
---------------------------------------------------------------------------

_______________________________________________
protege-user mailing list
[hidden email]
https://mailman.stanford.edu/mailman/listinfo/protege-user