Formalizing a Broader Recursion Coverage in SQL

  • Gabriel Aranda
  • Susana Nieva
  • Fernando Sáenz-Pérez
  • Jaime Sánchez-Hernández
Part of the Lecture Notes in Computer Science book series (LNCS, volume 7752)


SQL is the de facto standard language for relational databases and has evolved by introducing new resources and expressive capabilities, such as recursive definitions in queries and views. Recursion was included in the SQL-99 standard, but this approach is limited as only linear recursion is allowed, mutual recursion is not supported, and negation cannot be combined with recursion. In this work, we propose a new approach, called R-SQL, aimed to overcome these limitations and others, allowing in particular cycles in recursive definitions of graphs and mutually recursive relation definitions. In order to combine recursion and negation, we import ideas from the deductive database field, such as stratified negation, based on the definition of a dependency graph between relations involved in the database. We develop a formal framework using a stratified fixpoint semantics and introduce a proof-of-concept implementation.


Databases SQL Recursion Fixpoint Semantics 


Unable to display preview. Download preview PDF.

Unable to display preview. Download preview PDF.


  1. 1.
    Abiteboul, S., Hull, R., Vianu, V.: Foundations of Databases. Addison-Wesley (1995)Google Scholar
  2. 2.
    Codd, E.: A Relational Model for Large Shared Databanks. Communications of the ACM 13(6), 377–390 (1970)CrossRefzbMATHGoogle Scholar
  3. 3.
    Date, C.J.: SQL and relational theory: how to write accurate SQL code. O’Reilly, Sebastopol (2009)Google Scholar
  4. 4.
    Finkelstein, S.J., Mattos, N., Mumick, I.S., Pirahesh, H.: Expressing recursive queries in SQL. Technical report, ISO (1996)Google Scholar
  5. 5.
    Garcia-Molina, H., Ullman, J.D., Widom, J.: Database systems - the complete book, 2nd edn. Pearson Education (2009)Google Scholar
  6. 6.
    Houtsma, M.A.W., Apers, P.M.G.: Algebraic optimization of recursive queries. Data Knowl. Eng. 7, 299–325 (1991)CrossRefGoogle Scholar
  7. 7.
    ISO/IEC. SQL: 2008 ISO/IEC 9075 (1-4,9-11,13,14): 2008 Standard (2008)Google Scholar
  8. 8.
    Kaser, O., Ramakrishnan, C.R., Pawagi, S.: On the conversion of indirect to direct recursion. ACM Lett. Program. Lang. Syst. 2(1-4), 151–164 (1993)CrossRefGoogle Scholar
  9. 9.
    Kowalski, R.A.: Logic for data description. In: Logic and Data Bases, pp. 77–103 (1977)Google Scholar
  10. 10.
    Mumick, I.S., Pirahesh, H.: Implementation of magic-sets in a relational database system. SIGMOD Rec. 23, 103–114 (1994)CrossRefGoogle Scholar
  11. 11.
    Nieva, S., Sánchez-Hernández, J., Sáenz-Pérez, F.: Formalizing a Constraint Deductive Database Language based on Hereditary Harrop Formulas with Negation. In: Garrigue, J., Hermenegildo, M.V. (eds.) FLOPS 2008. LNCS, vol. 4989, pp. 289–304. Springer, Heidelberg (2008)CrossRefGoogle Scholar
  12. 12.
    Ramamohanarao, K., Harland, J.: An introduction to deductive database languages and systems. The VLDB Journal 3(2), 107–122 (1994)CrossRefGoogle Scholar
  13. 13.
    Reiter, R.: Towards a logical reconstruction of relational database theory. In: On Conceptual Modelling (Intervale), pp. 191–233 (1982)Google Scholar
  14. 14.
    Shepherdson, J.: Negation in logic programming. In: Minker, J. (ed.) Foundations of Deductive Databases and Logic Programming, pp. 19–88. Kaufmann, Los Altos (1988)Google Scholar
  15. 15.
    Tarski, A.: A lattice-theoretical fixpoint theorem and its applications. Pacific Journal of Mathematics 5, 285–309 (1955)MathSciNetCrossRefzbMATHGoogle Scholar
  16. 16.
    Ullman, J.: Database and Knowledge-Base Systems, Vols. I (Classical Database Systems) and II (The New Technologies). Computer Science Press (1995)Google Scholar
  17. 17.
    Zaniolo, C., Ceri, S., Faloutsos, C., Snodgrass, R.T., Subrahmanian, V.S., Zicari, R.: Advanced Database Systems. Morgan Kaufmann Publishers Inc. (1997)Google Scholar

Copyright information

© Springer-Verlag Berlin Heidelberg 2013

Authors and Affiliations

  • Gabriel Aranda
    • 1
  • Susana Nieva
    • 1
  • Fernando Sáenz-Pérez
    • 2
  • Jaime Sánchez-Hernández
    • 1
  1. 1.Dept. Sistemas Informáticos y ComputaciónUCMSpain
  2. 2.Dept. Ingeniería del Software e Inteligencia ArtificialUCMSpain

Personalised recommendations