Introduction
The Semantic Web aims to create a "web of linked data" using RDF triples and ontologies. However, the vast majority of enterprise data remains stored in traditional Relational Databases (RDBs). Bridging this gap requires more than just moving data; it requires translating the underlying logic and relationships without information loss. This paper presents a framework for automatically transforming RDBs into ontologies and translating SQL queries into equivalent SPARQL queries.
Methodology
The proposed approach consists of two primary phases implemented using the Apache Jena framework.
Phase 1: RDB to Ontology Transformation
The system first analyzes the database schema—including tables, primary keys, and foreign keys—to identify relationships. It then applies formal rules to generate OWL classes and RDF properties. A critical aspect of this phase is the mapping of database tuples to RDF triples. As shown in the mapping diagram, database row IDs and attribute values are systematically converted into Internationalized Resource Identifiers (IRIs) and literals.
Phase 2: Query Rewriting
Rather than translating raw SQL text, the authors translate Relational Algebra. By defining rules for fundamental operations like Selection ($\sigma$), Projection ($\Pi$), and Joins ($\infty$), the approach ensures mathematical consistency. To handle SQL's "null" values—which often cause data loss in naive RDF translations—the system utilizes SPARQL’s OPTIONAL and FILTER(BOUND(...)) patterns. This ensures that records with missing attributes are preserved in the semantic query results, maintaining 100% data parity.
Experimental Evaluation
The researchers evaluated their approach using two distinct datasets:
- RDBLAB: A custom database designed to test various relationship types (1:1, 1:M, N:M).
- Scaling Dataset: A synthetic dataset with over 100,000 rows and intentional null values to test performance and integrity at scale.
Key Results
The experimental results confirmed the effectiveness of the transformation rules:
- Data Integrity: In tests on the 100k-row dataset, the generated SPARQL queries returned the exact same number of results as the original SQL queries. In contrast, "naive" mappings that ignored null values lost nearly 17% of the data.
- Performance: The overhead of SPARQL execution was minimal. For a 70,000-row query, the transformed SPARQL query took only 0.075s, compared to 0.07s for native SQL.
Conclusion and Future Work
This framework provides a mathematically sound bridge between relational databases and the Semantic Web. By focusing on relational algebra and explicitly handling null values, it achieves lossless data transformation. Future work will focus on extending the rule set to support SQL aggregation functions (e.g., SUM, COUNT), GROUP BY clauses, and complex nested subqueries.
Summary updated