D2RQ如何配置多对多关系

D2RQ how to configue many to many relationship

我有一个数据库 tables,我正在将数据更改为 RDF。

到目前为止,我能够进行一对一操作,其中具有主键的行具有来自该行中的列的值,如下所示:

map:Artist a d2rq:ClassMap;
    d2rq:dataStorage map:database;
    d2rq:class to:Artist;
    d2rq:uriPattern "to:Artist/@@M3.ARTIST.ARTIST_ID@@";
    .

map:ArtistName a d2rq:PropertyBridge;
    d2rq:belongsToClassMap map:Artist;
    d2rq:property to:hasName;
    d2rq:column "M3.ARTIST.ARTIST_NAME";
    d2rq:datatype xsd:string;
    .

此处每个 Artist_ID 将成为三元组的主题,并且将有一个名为 hasName 的 属性 其值来自 ARTIST_NAME 列

到目前为止一切顺利,现在我有一个 table 像这样的多对多:

艺术家(table)专辑(Table)艺术家专辑(table)

艺术家专辑有专辑和艺术家的外键

请问我如何在 r2rq 中做到这一点?

我已经联系了 D2RQ 的人,这是他们的回复:

See here for an example that connects instances from two tables (but it's one to many, not many-to-many): http://d2rq.org/d2rq-language#example-refers

See here for an example that takes a property from a different table, and the table is joined via a many-to-many relationship table: http://d2rq.org/d2rq-language#example-join

Combine the two examples to address your scenario.

我按照他们说的做了,想出了这个映射

map:ArtistAlbum a d2rq:PropertyBridge;
    d2rq:property to:hasArtist;
    d2rq:belongsToClassMap map:Album;
    d2rq:refersToClassMap map:Artist;
    d2rq:join "blabla.ARTIST.ARTIST_ID = blabla.ARTISTALBUM.ARTIST_ID";
    d2rq:join "blabla.ARTISTALBUM.ALBUM_ID = blabla.ALBUM.ALBUM_ID";
    .

而且效果很好