Natural Language Interface to Databases
Share This Page
Relational databases cannot be used directly by people who do not have competence in the database technology, the internal database structure and the language used to interact with the database. Writing the SQL queries is not practical, especially when it involves comple logic. A natural way of interaction is highly desirable for non-technical business professionals to get the desired information directly and instantly without the dependence on another person.
The translation to SQL queries
SQL (Structured Query Language) is a standardized language for performing operations (queries, modifications, deletion, etc.) on relational dtabases. So, we are only dealing with the interrogation of a base that is done using the SELECT comand in always constructive way, whos syntax is the following:
By knowing this, when the user enters a request of the type:
Who are the customers from India?
The application does the conversion and executes a query like this:
SELECT name FROM customers WHERE country = ’India’;
And response to the user in natural way:
Keeping the context is most important to avoid the user from framing a lengthy question every time.
- What was the sales yesterday Application of Natural Language Interface to Databasesin Karnataka region?
- How about Kerala?
- What are the top 3 products sold there?
More complex questions are possible to answer by dynamically processing
the data, with the advantage of the grouping, aggregation, statistical and analytical features in SQL.
The key steps for the conversion is given below.
- Parse the natural language input into a parse tree using dependency syntax parser.
- Map the nodes in the parse tree to SQL key words, table names, column names, and values. Here users may choose the desired maping from ranked options.
- Adjust the structure of the parse tree to make it follow the structure of an SQL query. Here users may choose the desired structure from ranked options.
- Translate the parse tree to an SQL query.
- Exection of the SQL.
- Presentation of the result in natural way.
How Natural Language Processing (NLP) is used
The mechanism of Natural Language Processing involves two processes: Natural Language Understanding and Natural Language Generation(NLG).
- NLU or Natural Language Understanding tries to understand the meaning of the given text. The nature and structure of each word inside text must be understood for NLU. NLU tries to resolve lexical ambiguity, Syntactic Ambiguity, Semantic Ambiguity present in natural language. In this way, a mapping between the keywords of the input sentence and the keywords of the data model can be performed.
- NLG is the process of automatically produing text from structured data in a readable format with meaningful phrases and sentences.
Application of Natural Language Interface to Databases
- A better human-computer interface that could convert from a natural language into a computer language and vice versa. A natural language system could be the interface to a database system, such as for a travel agent to use in making reservations.
- A computer that could understand and process human language, enabling it to convert mass information either from eBooks or websites, into structured data, before stocking them into a huge database.
Author Credits: Mohan Babu Lankipalli, Sr. Associate – Data Science at 8K Miles Software Services and you can reach him here
Our SolutionsCloud Management Solutions
Cloud MFA Solution
Data lake management platform
Our ServicesCloud Consulting Services
Cloud Cost Optimization
Cloud Managed Services
Cloud DevOps Services
Cloud Engineering Services
Identity Access Management
Cloud Data Analytics