Ontology and Machine Learning Based SQL Query Rewriting and Optimization

Main Article Content

Meftah Lakehal, Mustapha Bourahla

Abstract

In this work, we present a hybrid approach that integrates supervised machine learning with semantic reasoning through ontology to optimize SQL queries in relational databases. The relational schema is first mapped to an OWL ontology, where domain knowledge and business constraints are encoded as TBox axioms. A labeled dataset of SQL queries is extracted from query logs and used to train a Random Forest Classifier to distinguish between simple and complex queries based on selected features such as number of joins, presence of WHERE clauses, and execution time. Complex queries are then rewritten using semantic rules defined in the ontology, allowing for more efficient execution by constraining unnecessary data retrieval. Experimental results demonstrate high accuracy and effectiveness of the proposed system, showing significant performance gains in query execution. This work highlights the value of combining knowledge representation with machine learning for intelligent and context-aware data access strategies

Article Details

Section
Articles