Large Language Model – Based Query Generation
Main Article Content
Abstract
The proposed to is designed to Retrieving information from relational databases typically requires proficiency in Structured Query Language (SQL). However, non-technical users often lack the necessary expertise to construct accurate SQL queries, creating a barrier to effective data access. To address this challenge, this paper proposes an LLM-based Query Generation System that translates natural language prompts into executable SQL queries. The system leverages pretrained large language models (LLMs), such as those developed by OpenAI, enhanced with schema-aware prompt engineering to ensure the generated queries align with the underlying database schema. Unlike traditional methods based on keyword matching, template filling, or handcrafted rules, the proposed system adapts flexibly across diverse domains and query structures.
A prototype implementation demonstrates how non-technical users can interact with databases by formulating requests in plain English. The system will automatically generate the corresponding SQL query with correct joins, filtering, and ordering clauses. This approach reduces dependency on database experts, enhances accessibility, and improves productivity in organizations where timely data retrieval is essential.