volume_mute

Natural Language to SQL System

publish date2026/06/11 07:14:53.963753 UTC

volume_mute

You need to design an architecture for a system that accepts natural language commands from users and translates them into SQL database queries. The system must parse the natural language input, identify the entities and relationships, and generate a valid SQL statement. Which of the following architectural patterns is most appropriate as the primary pattern, and which components would it include?

Correct Answer

Pipe and Filter (or language processing system architecture) - with pipeline stages: Lexical Analysis → Syntactic Analysis → Semantic Analysis → SQL Code Generation, sharing a Symbol Table and Syntax Tree via a central repository

Explanation

A natural language to SQL translator is a language processing system. The appropriate architecture is a Pipe and Filter pipeline: Lexical Analysis (tokenizes the natural language input) → Syntactic Analysis (parses sentence structure) → Semantic Analysis (identifies entities, attributes, and relationships in the database schema context) → SQL Code Generation (produces the SQL query). A shared Symbol Table and Syntax Tree act as a central repository connecting the pipeline stages. This is the standard language processing system architecture applied to a new domain.

Reference

Software Engineering, Ian Sommerville, 10th edition


Quizzes you can take where this question appears