Implementation of Chatbot for Generating Natural Language to SQL Queries

·

Authors: Rahmad Santosa, Hartantya Ainiyatuts Tsaniyah, Yoga Ari Tofan, Adetiya Bagus Nusantara, Radityo Prasetianto Wibowo
Year: 2026
Publisher: IPTEK The Journal for Technology and Science
Type: Journal
DOI / URL: https://doi.org/10.12962/j20882033.v37i2.9252


Abstract

This paper explores the practical implementation of a Chatbot designed to connect natural language communication with database interactions by generating Structured Query Language (SQL) queries. Utilizing the OpenAPI framework, a widely-used specification for building APIs, our approach aims to enhance the flexibility and interoperability of the ChatBot. The system not only interprets user queries expressed in natural language but also transforms them into syntactically correct and semantically meaningful SQL commands. This paper provides an overview of the current landscape of natural language processing (NLP) Chatbots, discusses the architecture and design considerations of our implementation, and highlights the methodology for training and fine-tuning using state-of-the-art NLP models. Real-world use cases are presented to showcase the practical applicability of the Chatbot, demonstrating its ability to handle various complexities inherent in natural language queries. This work contributes to the field by presenting a scalable and robust solution that combines NLP and database interactions through the utilization of OpenAPI, with potential implications for improving human-computer interactions within database systems.

Keywords: Chatbot, Few-shot Prompting, Natural Language to SQL, NL2SQL, OpenAI GPT-3.5, SQL Server


Citation

Long H, Cao D. BERT-based Text-to-SQL Generation Method With Question-table Content Enhancement and Template Filling. In: 2021 2nd International Conference on Information Science and Education (ICISE-IE); 2021. p. 969–973.

Simitsis A, Koutrika G, Ioannidis Y. Pr’ecis: From Unstructured Keywords as Queries to Structured Databases as Answers. VLDB Journal 2008 Jan;17(1):117–149.

Li F, Jagadish HV. Constructing an Interactive Natural Language Interface for Relational Databases. Proceedings of the VLDB Endowment 2014 Sep;8(1):73–84.

Baik C, Jagadish HV, Li Y. Bridging the Semantic Gap with SQL Query Logs in Natural Language Interfaces to Databases. In: 2019 IEEE 35th International Conference on Data Engineering (ICDE); 2019. p. 374–385.

Saha D, Floratou A, Sankaranarayanan K, Minhas UF, Mittal AR, “Ozcan F. ATHENA: An Ontology-driven System for Natural Language Querying Over Relational Data Stores. Proceedings of the VLDB Endowment 2016 Aug;9(12):1209–1220.

Fan Y, Ren T, He Z, Wang XS, Zhang Y, Li X. GenSql: A Generative Natural Language Interface to Database Systems. In: 2023 IEEE 39th International Conference on Data Engineering (ICDE); 2023. p. 3603–3606.

Popescu AM, Etzioni O, Kautz H. Towards a Theory of Natural Language Interfaces to Databases. In: Proceedings of the 8th International Conference on Intelligent User Interfaces (IUI ’03) New York, NY, USA: Association for Computing Machinery; 2003. p. 149–157.

Singh G, Solanki A. An Algorithm to Transform Natural Language Into SQL Queries for Relational Databases. Selforganizology 2016 sep;https://www.semanticscholar.org/paper/An-algorithm-to-transform-natural-language-into-SQL-Singh-Solanki/a50cd64211689b4fca6adee3031e35ba42c31765, accessed: Jun. 24, 2026.

Xu X, Liu C, Song D. SQLNet: Generating Structured Queries From Natural Language Without Reinforcement Learning. arXiv preprint arXiv:171104436 2017 Nov;.

Yu T, Zhang R, Yasunaga M, Tan YC, Lin XV, Li S, et al. SyntaxSQLNet: Syntax Tree Networks for Complex and CrossDomain Text-to-SQL Task. In: Riloff E, Chiang D, Hockenmaier J, Tsujii J, editors. Proceedings of the 2018 Conference on Empirical Methods in Natural Language Processing Brussels, Belgium: Association for Computational Linguistics; 2018. p. 1653–1663.

Katsogiannis-Meimarakis G, Koutrika G. A Survey on Deep Learning Approaches for Text-to-SQL. VLDB Journal 2023 Jul;32(4):905–936.

Qin B, et al. A Survey on Text-to-SQL Parsing: Concepts, Methods, and Future Directions. arXiv preprint arXiv:220813629 2022 Aug;.

Liu A, Hu X, Wen L, Yu PS. A Comprehensive Evaluation of ChatGPT’s Zero-shot Text-to-SQL Capability. arXiv preprint arXiv:230313547 2023 Mar;.

Nan L, et al. Enhancing Few-shot Text-to-SQL Capabilities of Large Language Models: A Study on Prompt Design Strategies. arXiv preprint arXiv:230512586 2023 May;.

Liu X, et al. A Survey of NL2SQL with Large Language Models: Where are we, and where are we going? arXiv preprint arXiv:240805109 2024 Aug;.

Kurniawan A, Abdiansah A, Utami AS. NL2SQL for Chatbot with Semantic Parsing Using Rule-Based Methods. Sriwijaya Journal of Informatics and Applications 2024;5(1).

Kanburoğlu AB, Tek FB. TUR2SQL: A Cross-Domain Turkish Dataset For Text-to-SQL. In: 2023 8th International Conference on Computer Science and Engineering (UBMK); 2023. p. 206–211.

Ionescu VM, Enescu MC. Using ChatGPT for Generating and Evaluating Online Tests. In: 2023 15th International Conference on Electronics, Computers and Artificial Intelligence (ECAI); 2023. p. 1–6.


Links