Generating SQL Queries Using Natural Language Syntactic Dependencies and Metadata

  • Alessandra Giordani
  • Alessandro Moschitti
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7337)


This research concerns with translating natural language questions into SQL queries by exploiting the MySQL framework for both hypothesis construction and thesis verification in the task of question answering. We use linguistic dependencies and metadata to build sets of possible SELECT and WHERE clauses. Then we exploit again the metadata to build FROM clauses enriched with meaningful joins. Finally, we combine all the clauses to get the set of all possible SQL queries, producing an answer to the question. Our algorithm can be recursively applied to deal with complex questions, requiring nested SELECT instructions. Additionally, it proposes a weighting scheme to order all the generated queries in terms of probability of correctness.

Our preliminary results are encouraging as they show that our system generates the right SQL query among the first five in the 92% of the cases. This result can be greatly improved by re-ranking the queries with a machine learning methods.


Natural Language Processing Question Answering Metadata Information Schema SQL 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Marie-Catherine de Marneffe, B.M., Manning, C.D.: Generating typed dependency parses from phrase structure parses. In: Proceedings LREC 2006 (2006)Google Scholar
  2. 2.
    Porter, M.: Porter stemmer,
  3. 3.
    Kate, R.J., Mooney, R.J.: Using string-kernels for learning semantic parsers. In: Proceedings of the 21st ICCL and 44th Annual Meeting of the ACL, pp. 913–920. Association for Computational Linguistics, Sydney (2006)Google Scholar
  4. 4.
    Popescu, A.M., Etzioni, O., Kautz, H.: Towards a theory of natural language interfaces to databases. In: Proceedings of the 2003 International Conference on Intelligent User Interfaces. Association for Computational Linguistics, Miami (2003)Google Scholar
  5. 5.
    Giordani, A., Moschitti, A.: Corpora for automatically learning to map natural language questions into sql queries. In: Proceedings of LREC 2010. European Language Resources Association (ELRA), Valletta (2010)Google Scholar
  6. 6.
    Minock, M., Olofsson, P., Näslund, A.: Towards Building Robust Natural Language Interfaces to Databases. In: Kapetanios, E., Sugumaran, V., Spiliopoulou, M. (eds.) NLDB 2008. LNCS, vol. 5039, pp. 187–198. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  7. 7.
    Ruwanpura, S.: Sq-hal: Natural language to sql translator,
  8. 8.
    Giordani, A., Moschitti, A.: Syntactic Structural Kernels for Natural Language Interfaces to Databases. In: Buntine, W., Grobelnik, M., Mladenić, D., Shawe-Taylor, J. (eds.) ECML PKDD 2009. LNCS, vol. 5781, pp. 391–406. Springer, Heidelberg (2009)CrossRefGoogle Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2012

Authors and Affiliations

  • Alessandra Giordani
    • 1
  • Alessandro Moschitti
    • 1
  1. 1.Department of Computer Science and EngineeringUniversity of TrentoPovoItaly

Personalised recommendations