RÉGIMEN MUNICIPAL
las 16:00 horas del 29 de marzo del 2012, de la sociedad Costa
S. A., donde se reforma la cláusula del domicilio de la administración,
Mapping languages defined by the Semantic Web community can be used to transform non-RDF data source to RDF. The rules represent the GAV mappings that define the concepts of an ontology as a set of views over heterogeneous data sources. Such transformation can also be used to transform legacy data bases as well as semi-structured data sources published on the Web. R2RML and RML are exemplar rule- based languages that are widely used for these tasks. Next, we introduce these two mapping languages in detail.
R2RML – RDB to RDF Mapping Language
R2RML is a W3C Recommendation [28] for transformation of relational databases to RDF. R2RML is a language for expressing customized mappings from relational databases to RDF datasets. Such mappings provide the ability to view existing relational data in the RDF data model, expressed in a structure and
Figure 2.5: Overview of R2RML Triple Maps
target vocabulary of the mapping author’s choice. An R2RML mapping is represented as a Triple Map, a rule that maps each row in the logical table to a number of RDF triple. A Triple Map have the following parts (illustrated8in Figure 2.5):
‚ A Logical Table (rr:logicalTable) refers to a base table, a view, or a valid SQL query to retrieve from the input database. It comprises the following components:
– SQL Base Table or View (rr:tableName) specifies the table or view name of the base table or view.
– R2RML View (rr:sqlQuery and rr:sqlVersion) specifies an SQL SELECT query to be executed against the input database.
‚ A Subject map (rr:subjectMap) defines the subjects of the generated RDF triples. Subjects can be defined as IRIs or Blank Nodes. Zero or more class type of subjects can also be defined. ‚ Zero or More Predicate-Objece Maps (rr:predicateObjectMap) that in turn consists of:
– Predicate Maps (rr:predicateMap) indicates the predicate of the RDF triple and should be a valid IRI;
– Object Maps (rr:objectMap) indicate the object of the RDF triple;
– Referencing Object Map (rr:refObjectMap) that indicates the reference to another Triple Map, if not specified as Object Map.
RML – RDF Mapping Language
RDF Mapping Language (RML) extends R2RML by generalizing to heterogeneous data sources. RML is a generic mapping language defined for expressing customized mappings from heterogeneous data sources, e.g., RDB, CSV, XML, JSON, to the RDF data model. Each mapping rule in RML is represented as a Triple Map which consists of the following parts9, illustrated10in Figure 2.6;
‚ A Logical Source (rr:logicalSource) that refers to a data source from where data is collected; it is composed of the following components:
8https://www.w3.org/TR/r2rml/images/triples-map.png
9http://rml.io/RMLmappingLanguage.html
2.2 Semantic Web
Figure 2.6: RML mapping schema
– Source (rml:source) - is an input source, can be JSON, XML, CSV, or a data management system such as RDB, NoSQL store;
– Iterator (rml:iterator) - is not required when it comes to tabular input sources, like relational databases. It is needed in case of hierarchical or structured data sources. The iterator (rml:iterator) determines the iteration pattern by the input source and specifies the extraction of the data displayed during each iteration;
– Reference Formulation (rr:referenceFormulation) - as RML deals with different data serializations with various ways to refer to their elements, RML defines the reference. Such reference is specified based on the source of the input data file, e.g. in case of a JSON file, a Reference Formulation would be "JSONPath", in case of an XML file, a Reference Formulation would be "XPath".
‚ A Subject Map (rr:subjectMap) - defines the subject of the generated RDF triples.
‚ Zero or more Predicate-Object Maps (rr:predicateObjectMap), combining:
– Predicate Maps (rr:predicate) expressing the predicate of the RDF triple and must be a valid IRIs;
– Object Maps (rr:objectMap) expressing the object of the RDF triple and must be either IRIs, Blank Nodes or Literals;
– A Referencing Object Map, that indicates the reference to another (existing) Triples Maps (rr:parentTriplesMap) and can have zero or more join conditions.
Each Predicate-Object Map should have at least one Predicate Map and one either Object Map or Referencing Object Map.
Listing 2.1: Example RML Mapping @ p r e f i x r r : < h t t p : / / www. w3 . org / ns / r2rml # >.
@ p r e f i x r m l : < h t t p : / / semweb . mmlab . be / ns / rml # >. @ p r e f i x q l : < h t t p : / / semweb . mmlab . be / ns / q l # >. @ p r e f i x v o c a b : < h t t p : / / example . com / vocab / >. @ p r e f i x x s d : < h t t p : / / www. w3 . org / 2 0 0 1 / XMLSchema# >. <# AirportMapping >
r m l : l o g i c a l S o u r c e [
r m l : s o u r c e " h t t p :/ / www. example . com / drug s . csv " ; r m l : r e f e r e n c e F o r m u l a t i o n q l : CSV
] ;
r r : s u b j e c t M a p [
r r : t e m p l a t e " h t t p :/ / example . com / Drug / { name} "; r r : c l a s s v o c a b : Drug ] ; r r : p r e d i c a t e O b j e c t M a p [ r r : p r e d i c a t e r d f s: l a b e l ; r r : o b j e c t M a p [ r m l : r e f e r e n c e " Name " ] ] ; r r : p r e d i c a t e O b j e c t M a p [ r r : p r e d i c a t e v o c a b : c h e m i c a l F o r m u l a ; r r : o b j e c t M a p [ r m l : r e f e r e n c e " F o r m u l a "; r r :d a t a t y p e x s d : s t r i n g ] ] ; r r : p r e d i c a t e O b j e c t M a p [ r r : p r e d i c a t e v o c a b : a v g W e i g h t ; r r : o b j e c t M a p [ r m l : r e f e r e n c e " Avg W e i g h t "; r r :d a t a t y p e x s d : d e c i m a l ] ] .
Table 2.1: Example drugs.csv
Name, Formula, Avg Weight
Docetaxel, C43H53NO14, 807.8792
Listing 2.2: Example RDF Output
@ p r e f i x r d f: < h t t p : / / www. w3 . org /1999/02/22 ´r d f´s y n t a x ´n s #>. @ p r e f i x v o c a b : < h t t p : / / example . com / vocab / >.
@ p r e f i x x s d : < h t t p : / / www. w3 . org / 2 0 0 1 / XMLSchema# >. @ p r e f i x d r u g : < h t t p : / / example . com / Drug / > .
d r u g : D o c e t a x e l r d f: t y p e v o c a b : Drug ;
r d f s: l a b e l " D o c e t a x e l ";
v o c a b : c h e m i c a l F o r m u l a " C43H53NO14 "^^ x s d : s t r i n g ; v o c a b : a v g W e i g h t " 8 0 7 . 8 7 9 2 "^^ x s d : d e c i m a l .