A Secure and Efficient LLM-Based System for Natural Language Query-to-SQL Translation in IoT Data Management
Abstract
Structured data embodies vast reservoirs of actionable knowledge, yet non-technical users often lack the tools to effectively access or leverage these resources. This paper presents a novel middleware system architecture that harnesses Large Language Models (LLMs) to translate natural language queries (NLQs) into executable SQL statements, enabling seamless interaction with relational databases without requiring technical expertise. To bridge a critical gap in existing research, the proposed system integrates a robust security framework featuring multi-factor authentication and fine-grained, role-based access control. A comprehensive evaluation was conducted using over 813,000 real spatio-temporal IoT samples from the H2020-AFarCloud international project, comparing both general-purpose LLMs and models fine-tuned for NLQ-to-SQL translation. Two complementary evaluation metrics—Execution Accuracy (EX) and Valid Efficiency Score (VES)—were employed to assess syntactic correctness, semantic fidelity, and runtime efficiency. Experimental results show that GPT-o3 mini-high achieves the highest overall performance in terms of average VES, while DeepSeek R1 exhibits the most consistent behavior across heterogeneous query scenarios, as reflected by lower performance variability. These findings underscore the interplay between model capability and computational efficiency, demonstrating the potential of LLM-driven middleware to democratize structured data access and enhance data-driven decision-making.
Fields of Study & Subjects
Natural Language Processing Techniques
Semantic Web and Ontologies
Big Data and Digital Economy
Publication details
- Journal / source
- IEEE Access
- Publisher
- Institute of Electrical and Electronics Engineers (IEEE)
- Volume
- 14
- Pages
- 28435–28456
- Publication date
- 1 January 2026