Re: Many-to-Many table in R2RML

Richard,

On Fri, Jul 29, 2011 at 9:07 AM, Richard Cyganiak <richard@cyganiak.de>wrote:

> Juan,
>
> I'd solve this like so:
>
> <#LinkMap_1_2>
>    rr:logicalTable [ rr:tableName "enrolled" ];
>     rr:subjectMap [ rr:template "http://data.example.com/student/{s_id}"
> ];
>     rr:predicateObjectMap [
>        rr:predicateMap [ rr:predicate ex:isEnrolled ];
>         rr:objectMap [ rr:template "http://data.example.com/course/{c_id}"
> ];
>    ].
>
>

Ok. I should of realized this. Makes sense.

Could you please add this example (or something similar) to the specs. I
think it would be really useful.

So is this wrong then:

<#TriplesMap1>
    rr:logicalTable [ rr:tableName "student"; ]
    rr:subjectMap [
        rr:template "http://data.example.com/student/{s_id}";
        rr:class ex:Student;
    ];
    rr:predicateObjectMap [
        rr:predicateMap [ rr:predicate ex:name; ];
        rr:objectMap [ rr:column "name" ];
    ];
    rr:predicateObjectMap [
     rr:predicateMap [ rr:predicate ex:isEnrolled ] ;
        rr:refObjectMap [ rr:parentTriplesMap <#TriplesMap2> ];
    ].

<#TriplesMap2>
    rr:logicalTable [ rr:tableName "course"; ]
    rr:subjectMap [
        rr:template "http://data.example.com/course/{c_id}";
        rr:class ex:Course;
    ];
    rr:predicateObjectMap [
        rr:predicateMap [ rr:predicate ex:title; ];
        rr:objectMap [ rr:column "title" ];
    ];
    rr:predicateObjectMap [
     rr:predicateMap [ rr:predicate ex:hasStudent ] ;
        rr:refObjectMap [ rr:parentTriplesMap <#TriplesMap1> ];
    ].




> If you had made the subjectMap and objectMap reusable by giving them IRIs,
> then this could be written even shorter:
>
> <#LinkMap_1_2>
>    rr:logicalTable [ rr:tableName "enrolled" ];
>    rr:subjectMap :studentMap;
>     rr:predicateObjectMap [
>        rr:predicateMap [ rr:predicate ex:isEnrolled ];
>         rr:objectMap :courseMap;
>    ].
>

ok. but if I'm not wrong, it's not explicit in the spec that you can give a
subjectMap and objectMap a URI. or is it?


>
> There's ISSUE-54 about simplifying constant-valued term maps, which would
> simplify the predicate map further:
> http://www.w3.org/2001/sw/rdb2rdf/track/issues/54
>
> <#LinkMap_1_2>
>    rr:logicalTable [ rr:tableName "enrolled" ];
>    rr:subjectMap :studentMap;
>    rr:predicateObjectMap [
>        rr:predicate ex:isEnrolled;
>        rr:objectMap :courseMap;
>    ].
>
> A case can be made for further syntactic sugar in the case where a triples
> map only has a single predicate-object map:
>
> <#LinkMap_1_2>
>    rr:logicalTable [ rr:tableName "enrolled" ];
>    rr:subjectMap :studentMap;
>    rr:predicate ex:isEnrolled;
>    rr:objectMap :courseMap.
>
> A case can be made for further syntactic sugar in the case where one
> doesn't need a logical table to be re-usable. In that case it would be
> simpler to just stick rr:tableName, rr:sqlQuery and so on directly onto the
> triples map:
>
> <#LinkMap_1_2>
>    rr:tableName "enrolled";
>    rr:subjectMap :studentMap;
>    rr:predicate ex:isEnrolled;
>    rr:objectMap :courseMap.
>
>
YES!! Can we please have this!!!


> And that's really about as short as one can get.
>

Thanks!


>
> Best,
> Richard
>
>
>
> On 29 Jul 2011, at 14:10, Juan Sequeda wrote:
>
> > Richard, all
> >
> >
> > This may be a dumb question, but I haven't been able to figure out how to
> represent a many-to-many relationship in r2rml. For example:
> >
> > Student(s_id, name)
> > Course(c_id, title)
> > Enrolled(s_id, c_id)
> >
> > Where Enrolled is the many-to-many relationship.
> >
> > These are the TripleMaps for the Student and Course table:
> >
> > <#TriplesMap1>
> >     rr:logicalTable [ rr:tableName "student"; ]
> >     rr:subjectMap [
> >         rr:template "http://data.example.com/student/{s_id}";
> >         rr:class ex:Student;
> >     ];
> >     rr:predicateObjectMap [
> >         rr:predicateMap [ rr:predicate ex:name; ];
> >         rr:objectMap [ rr:column "name" ];
> >     ].
> >
> > <#TriplesMap2>
> >     rr:logicalTable [ rr:tableName "course"; ]
> >     rr:subjectMap [
> >         rr:template "http://data.example.com/course/{c_id}";
> >         rr:class ex:Course;
> >     ];
> >     rr:predicateObjectMap [
> >         rr:predicateMap [ rr:predicate ex:title; ];
> >         rr:objectMap [ rr:column "title" ];
> >     ].
> >
> > I assume that I should add a predicateObjectMap to TriplesMap1 (student)
> which is going to connect to TriplesMap2 (course), but the joinCondition is
> on the enrolled table.
> >
> > <#TriplesMap1>
> > rr:predicateObjectMap [
> >         rr:predicateMap [ rr:predicate ex:isEnrolled; ];
> >         rr:objectMap [
> >             rr:parentTriplesMap <#TriplesMap2>;
> >             rr:joinCondition [
> >                 rr:child "?????";
> >                 rr:parent "???";
> >             ];
> >         ].
> >
> > How is this suppose to be done? And could you add an example in the
> specs.
> >
> > Thanks!
> >
> > Juan Sequeda
> > +1-575-SEQ-UEDA
> > www.juansequeda.com
>
>

Received on Friday, 29 July 2011 14:20:19 UTC