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.
Glossary
R2RML

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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
Core concepts and standards that define how R2RML maps relational data to RDF knowledge graphs.
Direct Mapping
A default, convention-based approach to generating RDF from relational data without a custom mapping document. The W3C Direct Mapping standard defines an automatic transformation where:
- Each table becomes a class
- Each column becomes a predicate
- Each row becomes an entity with a unique IRI
R2RML extends this by allowing customized, fine-grained control over the mapping process, overriding the default behavior when needed.
Triples Maps
The core building block of an R2RML mapping document. Each Triples Map defines how to generate RDF triples from a logical source table or SQL query. It consists of three components:
- Logical Source: The input table or SQL view
- Subject Map: Generates the subject IRI for each row
- Predicate-Object Maps: Define the properties and their values
Multiple Triples Maps can target the same logical source to generate different RDF shapes.
Term Maps
The mechanism for generating RDF terms (IRIs, blank nodes, or literals) from database columns. R2RML defines three term types:
- Constant-valued: Always produces the same RDF term
- Column-valued: Uses the value from a specific SQL column
- Template-valued: Constructs IRIs using string templates with column placeholders like
http://example.com/entity/{ID}
Term maps also specify the datatype and language tag for literals.
Referencing Object Maps
The R2RML mechanism for expressing foreign key relationships as RDF predicates. Instead of generating a literal value, a Referencing Object Map uses a join condition to identify the subject IRI of a related row. This enables:
- Parent-child relationships between entities
- Many-to-one navigation through foreign keys
- Generation of object properties rather than datatype properties
The join condition specifies the parent and child columns that define the relationship.
SQL Views as Logical Sources
R2RML allows arbitrary SQL queries to serve as logical sources, not just base tables. This enables:
- Denormalization: Flattening joins into a single mapping source
- Computed columns: Generating derived values via SQL functions
- Filtering: Excluding rows that shouldn't appear in the RDF
- Aggregation: Pre-computing summary data before mapping
This flexibility means complex business logic can be pushed to the database layer before RDF generation.
R2RML vs SPARQL-Generate
While R2RML focuses on relational-to-RDF mapping, SPARQL-Generate extends SPARQL for mapping non-RDF data sources (XML, JSON, CSV) to RDF. Key distinctions:
- R2RML: Tightly coupled to SQL databases and JDBC connections
- SPARQL-Generate: Uses iterator patterns and binding functions for heterogeneous formats
- Both produce standard RDF graphs but target fundamentally different source paradigms
Choose R2RML for relational databases; SPARQL-Generate for APIs and document stores.

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.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us