Inferensys

Glossary

R2RML

R2RML (RDB to RDF Mapping Language) is a W3C recommendation that defines a language for expressing customized mappings from relational databases to RDF datasets, enabling the generation of virtual or materialized knowledge graphs.
Knowledge engineer constructing knowledge base on laptop, document hierarchy visible, casual office setup.
W3C RECOMMENDATION

What is R2RML?

R2RML (RDB to RDF Mapping Language) is a W3C recommendation that defines a language for expressing customized mappings from relational databases to RDF datasets, enabling the generation of virtual or materialized knowledge graphs.

R2RML is a W3C-standardized language that allows users to define how data stored in a relational database can be transformed into the Resource Description Framework (RDF) . It specifies a mapping between a relational schema and a target ontology or vocabulary, treating each database table as a logical source for generating RDF triples. This process enables the creation of a virtual RDF graph that can be queried via SPARQL without physically copying the underlying SQL data.

A core component of R2RML is the Triples Map, which defines a rule for converting a logical table row into a set of RDF triples. It uses a rr:subjectMap to generate the subject URI from primary keys, and rr:predicateObjectMap constructs to define properties and their values. R2RML supports SQL views and named queries, allowing complex transformations and joins to be expressed directly in the mapping, bridging the gap between legacy relational systems and semantic knowledge graphs.

W3C RECOMMENDATION

Key Features of R2RML

R2RML (RDB to RDF Mapping Language) is a W3C recommendation that defines a language for expressing customized mappings from relational databases to RDF datasets. It enables the generation of virtual or materialized knowledge graphs directly from existing SQL data without modifying the underlying schema.

01

Logical Tables

Defines the source of data for mapping. A logical table can be a base table, a SQL view, or an inline SQL query (R2RML View). This abstraction allows mappers to treat any SQL result set as a virtual RDF source, enabling complex joins and transformations before triplification without altering the physical database schema.

3 Types
Logical Table Sources
02

Triples Maps

The core mapping unit that defines how a row in a logical table maps to a set of RDF triples. Each Triples Map consists of exactly one Logical Table and one Subject Map, plus zero or more Predicate-Object Maps. This structure cleanly separates the source query from the target graph pattern.

03

Term Maps & Template Generation

Term Maps generate RDF terms (IRIs, blank nodes, or literals) from column values. They support:

  • Constant-valued: Always produce the same term
  • Column-valued: Directly use a column's SQL value
  • Template-valued: Use string templates like http://example.com/entity/{ID} to construct IRIs with column references, enabling deterministic URI minting from primary keys.
04

Referencing Object Maps

Enables the creation of relationships between entities using foreign key joins. A Referencing Object Map specifies a parent Triples Map and join conditions between child and parent logical table columns. This generates object properties linking subjects across different tables, preserving relational integrity in the graph.

05

Default & Named Graphs

Controls which RDF graph receives the generated triples. Each Triples Map can specify a default graph or one or more named graphs via graph maps. This enables multi-tenancy, provenance tracking, and dataset partitioning directly from the mapping layer, supporting SPARQL quad patterns.

06

SQL Datatype & Language Mapping

Automatically maps SQL data types to XSD datatypes (e.g., INTEGER to xsd:integer, TIMESTAMP to xsd:dateTime). Term Maps can also specify a language tag for string literals using a column reference or constant. This ensures semantic precision and multilingual support in the generated RDF.

R2RML CLARIFIED

Frequently Asked Questions

Direct answers to the most common questions about the W3C standard for mapping relational data to RDF knowledge graphs.

R2RML (RDB to RDF Mapping Language) is a W3C recommendation that defines a declarative language for expressing customized mappings from relational databases to RDF datasets. It works by specifying logical tables (SQL queries or base tables) and defining triples maps that dictate how each row generates RDF subjects, predicates, and objects. A triples map consists of a subject map (generating the resource URI using templates or column references) and multiple predicate-object maps (generating property assertions). The engine processes each row against these rules to produce a virtual or materialized RDF graph, enabling SPARQL querying over existing relational infrastructure without physically migrating data.

Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.