Context-Aware SQL Query Generation: Enhancing Natural Language Interaction & Query Correlation in Relational Database
M.Maragadhavalli Meenakshi, Selvi M, Srimathi R, A Aravindhan · 2025
In the era of data-driven decision-making, efficiently interacting with large databases is crucial for organizations across various sectors. Traditional SQL query generation methods often struggle with the complexity and variability of user queries, resulting in inefficiencies and inaccuracies. This paper presents a novel approach to leveraging a large language model (LLM) for dynamic SQL query generation; by utilizing advanced context-aware prompting techniques, the system effectively understands user intents in natural language. The system enhances the accuracy of subsequent queries, significantly improving data retrieval efficiency. The proposed framework supports dynamic relational database interactions, allowing seamless execution of generating queries while maintaining contextual continuity across user sessions. This enriches the user experience by providing coherent responses and accessible results. Although existing methodologies, such as RSQLG and TypeSQL have made strides in query automation, they face limitations, including insufficient support for complex SQL operations and challenges with multilingual commands. The system addresses these issues through advanced LLM techniques, the model's architecture, training methodologies, and various database management practices, and the findings bridge the gap between non-technical users and complex database systems, improving data accessibility and informed decision-making.