Join, one or two mappings?

I don't know the implementation details of mappings and was wondering if it would be better to have one or two mappings when there is a join involved if the join was only for a single triple or would it not make a difference?

say I had something like (completely contrived example)

:{id} ex:firstName {firstName};
        ex:lastName {lastName};
        ex:birthPlace {birthplaceName};
sm:map [
    sm:query """
        SELECT people.firstName, people.lastName, places.birthPlace FROM people JOIN places ON people.birthPlaceId = places.id
    """;
]

or

:{id} ex:firstName {firstName};
        ex:lastName {lastName};
sm:map [
    sm:query """
        SELECT people.firstName, people.lastName, places.birthPlace FROM people
    """;
]

:{id} ex:birthPlace {birthplaceName};
sm:map [
    sm:query """
        SELECT people.firstName, people.lastName, places.birthPlace FROM people JOIN places ON people.birthPlaceId = places.id
    """;
]

The first will generally suffice. However if you don't ask for the birthplace in your query and there's no foreign key, we need to retain the join. If we didn't, the SQL query could return results where the birthplace id has no corresponding record in the places table.

Thanks. Would I be correct in saying that the best way to approach mappings is to simply make sure you're logically getting what is correct and mostly trust that the sparql optimizer, sql optimizer and sparql to sql translation engine will do the right thing?

I'm getting to know the geonames database and it doesn't have an official schema so I'm having to cobble it together from blog posts and reverse engineering. They also don't publish the rdf mappings so I'm having to try and figure out how they got what they did by looking at the rdf they publish and the database. I'm hoping it will make a good example of the benefit of using semantic web technologies. "See all this work trying to figure out what this and that means? Well here is is all explicitly stated and machine readable.". There also seem to be a lot of opportunities to make it a better dataset.

So you have created a SQL schema for it? Most SQL schemas are normalized to individual entities which can be represented as IRIs in RDF. The lowest level mapping into Stardog gives you the most flexibility. You can always define higher level views with reasoning or materialized updates. This is the way the "default mapping" works. We create a class for each table and map each field of the table to a property in RDF.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.