LLM-based Contextual Query Generation on Relational Databases

In this research paper, we propose an algorithm to incorporate advanced prompting engineering strategies for large language models (LLMs) to query SQL databases in response to user queries relevant to the database. Plan-based querying, mitigating middle-forgetting, optimized context retention and Chain-of-Thought (CoT) prompting have been incorporated into the algorithm to aid with higher quality precision and reliability of the SQL queries generated. The proposed algorithm achieves over an accuracy of 96% in user response relevance and query generation. Also, a 94% consistency rate in response coherence. Our work enhances the retrieval of data from SQL databases and furthers the quality of Retrieval Augmented Generation (RAG) on databases.

Authors

Institutions

Publication Details

Published
2025-06-20
DOI
https://doi.org/10.1109/conit65521.2025.11167865
Citations
1
Primary Topic
Data Management and Algorithms
Type
article
Field-Weighted Citation Impact
1.49
Controls
|||
ALL TIME
JAN
FEB
MAR
APR
MAY
JUN
JUL
AUG
SEP
OCT
article

LLM-based Contextual Query Generation on Relational Databases

Farooque Azam, Vilohit Tapashetti, Ashwinikumar U Motagi
1 citations
Data Management and Algorithms
1.49
article

LLM-based Contextual Query Generation on Relational Databases

Farooque Azam, Vilohit Tapashetti, Ashwinikumar U Motagi
article en
1 citations

Abstract

In this research paper, we propose an algorithm to incorporate advanced prompting engineering strategies for large language models (LLMs) to query SQL databases in response to user queries relevant to the database. Plan-based querying, mitigating middle-forgetting, optimized context retention and Chain-of-Thought (CoT) prompting have been incorporated into the algorithm to aid with higher quality precision and reliability of the SQL queries generated. The proposed algorithm achieves over an accuracy of 96% in user response relevance and query generation. Also, a 94% consistency rate in response coherence. Our work enhances the retrieval of data from SQL databases and furthers the quality of Retrieval Augmented Generation (RAG) on databases.

Electronics Corporation of India (IN), REVA University (IN)
Openalex Percentile: Top 14%
Data Management and Algorithms
1.49
AI Navigator

Ask Laika to Summarize, Analyze, and Connect papers live on the map.

Summarize Papers & Methodologies

Extract key findings, datasets, and comparative methods across publications.

Benchmark Rankings & Visual Analytics

Rank top research institutions, authors, funders, topics, and journals by Field-Weighted Citation Impact (FWCI) and paper volume with instant charts.

Connect Distant Disciplines

Bridge topological clusters on the map to find hidden collaborative intersections.