Software & Systems Modeling

, Volume 18, Issue 1, pp 769–791 | Cite as

SQL-PL4OCL: an automatic code generator from OCL to SQL procedural language

  • Marina EgeaEmail author
  • Carolina DaniaEmail author
Regular Paper


In this paper, we introduce a SQL-PL code generator for OCL expressions that, in contrast to other proposals, is able to map OCL iterate and iterator expressions thanks to our use of stored procedures. We explain how the mapping presented here introduces key differences to the previous version of our mapping in order to (i) simplify its definition, (ii) improve the evaluation time of the resulting code, and (iii) consider OCL three-valued evaluation semantics. Moreover, we have implemented our mapping to target several relational database management systems, i.e., MySQL, MariaDB, PostgreSQL, and SQL server, which allows us to widen its usability and to benchmark the evaluation time of the SQL-PL code produced.


OCL UML SQL Stored procedures Code generator 


  1. 1.
    Armonas, A., Nemuraité, L.: Pattern based generation of full-fledged relational schemas from UML/OCL models. Inf. Technol. Control, 35(1), (2006)Google Scholar
  2. 2.
    Basin, D., Clavel, M., Egea, M., de Dios, M.A.G., Dania, C., Ortiz, G., Valdazo, J.: Model-driven development of security-aware guis for data-centric applications. In: Foundations of Security Analysis and Design VI—FOSAD Tutorial Lectures, volume 6858 of LNCS, pp. 101–124. Springer, (2011)Google Scholar
  3. 3.
    Basin, D.A., Clavel, M., Doser, J., Egea, M.: Automated analysis of security-design models. Inf. Softw. Technol. 51(5), 815–831 (2009)CrossRefGoogle Scholar
  4. 4.
    Berrabah, D., Boufarès, F.: Constraints checking in UML class diagrams: SQL vs OCL. In: Wagner, R., Revell, N., Pernul, G. (eds.) Database and Expert Systems Applications, 18th International Conference, DEXA 2007, Regensburg, Germany, September 3–7, 2007, Proceedings, volume 4653 of LNCS, pp. 593–602. Springer, (2007)Google Scholar
  5. 5.
    Carlos, X.D., Sagardui, G., Trujillo, S.: MQT, an approach for run-time query translation: From EOL to SQL. In: Brucker, A.D., Dania, C., Georg, G., Gogolla, M. (eds.) Proceedings of the 14th International Workshop on OCL and Textual Modelling co-located with 17th International Conference on Model Driven Engineering Languages and Systems (MODELS 2014), Valencia, Spain, September 30, 2014, volume 1285 of CEUR Workshop Proceedings, pp. 13–22., (2014)Google Scholar
  6. 6.
    Clavel, M., Egea, M., de Dios, M.A.G.: ECEASST building an efficient component for OCL evaluation. ECEASST, 15, 27–33 (2008)Google Scholar
  7. 7.
    Cortázar, S.C.: Transformación de las restricciones OCL de un esquema UML a consultas de SQL. trabajo de fin de grado. Technical report, Universidad Carlos III de Madrid, (2012).
  8. 8.
    Cosentino, V.: A model-based approach for extracting business rules out of legacy information systems. PhD thesis, École des mines de Nantes, France (2013)Google Scholar
  9. 9.
    Dania, C.: MySQL4OCL: Un compilador de OCL a MySQL. Master thesis. Universidad Complutense de Madrid (2011)Google Scholar
  10. 10.
    Dania, C. Egea, M.: SQLPL4OCL tool (2016).
  11. 11.
    Demuth, B., Hußmann, H.: Using UML/OCL Constraints for Relational Database Design. In: France, R.B., Rumpe, B. (eds.) UML, volume 1723 of LNCS, pp. 598–613. Springer, (1999)Google Scholar
  12. 12.
    Demuth, B., Hußmann, H., Loecher, S.: OCL as a Specification Language for Business Rules in Database Applications. In: Gogolla, M., Kobryn, C. (eds.) UML, volume 2185 of LNCS, pp. 104–117. Springer, (2001)Google Scholar
  13. 13.
    Egea, M., Dania, C., Clavel, M.: MySQL4OCL: A stored procedure-based MySQL code generator for OCL. ECEASST, 36, (2010)Google Scholar
  14. 14.
    I.O. for Standardization. Object Management Group Object Constraint Language (OCL), (2012).
  15. 15.
    Heidenreich, F., Wende, C., Demuth, B.: A framework for generating query language code from OCL invariants. ECEASST, 9, (2008)Google Scholar
  16. 16.
    Kleppe, A., Bast, W., Warmer, J.B., Watson, A.: MDA Explained: The Model Driven Architecture–Practice and Promise. Addison-Wesley, Boston (2003)Google Scholar
  17. 17.
    MariaDB (2016)
  18. 18.
  19. 19.
    Monperrus, M., Jézéquel, J., Baudry, B., Champeau, J., Hoeltzener, B.: Model-driven generative development of measurement software. Softw. Syst. Model. 10(4), 537–552 (2011)Google Scholar
  20. 20.
    MySQL 5.7 Reference Manual.
  21. 21.
    Object Management Group: Common Warehouse Metamodel specification. (March 2003). OMG document available at
  22. 22.
    Object Management Group: Object Constraint Language specification. (May 2006). OMG document available at
  23. 23.
    Object Management Group: Object constraint language specification version 2.4. Technical report, OMG, (2014).
  24. 24.
    Object Management Group: Unified modeling language version 2.5. Technical report, OMG, (2015).
  25. 25.
    Oriol, X., Teniente, E.: Incremental checking of OCL constraints through SQL queries. In: Brucker, A.D., Dania, C., Georg, G., Gogolla, M. (eds.) Proceedings of the 14th International Workshop on OCL and Textual Modelling co-located with 17th International Conference on Model Driven Engineering Languages and Systems (MODELS 2014), Valencia, Spain, September 30, 2014., volume 1285 of CEUR Workshop Proceedings, pp. 23–32., (2014)Google Scholar
  26. 26.
    Pinet, F., Kang, M., Vigier, F.: Spatial Constraint Modelling with a GIS Extension of UML and OCL: Application to Agricultural Information Systems. In: Wiil, U.K. (ed), Metainformatics, volume 3511 of LNCS, pp. 160–178. Springer, (2004)Google Scholar
  27. 27.
    PL/pgSQL - SQL procedural language (2016).
  28. 28.
    Schmidt, A.: Untersuchungen zur Abbildung von OCL-ausdrücken auf SQL. Master’s thesis, Institut für Softwaretechnik II - Technische Universität Dresden, Germany, (1998)Google Scholar
  29. 29.
    Siripornpanit, N., Lekcharoen, S.: An adaptive algorithms translating and back-translating of object constraint language into structure query language. In: International Conference on Information and Multimedia Technology, 2009. ICIMT’09, pp. 149–151. IEEE, (2009)Google Scholar
  30. 30.
    Sobotka, P.: Transformation from OCL into SQL, 2012. Master thesis. Charles University in Prague.
  31. 31.
    ISO/IEC 9075-(1–10) Information technology—Database languages—SQL. Technical report, International Organization for Standardization, (2011).
  32. 32.

Copyright information

© Springer-Verlag Berlin Heidelberg 2017

Authors and Affiliations

  1. 1.Minsait (by Indra)MadridSpain
  2. 2.IMDEA Software InstituteMadridSpain

Personalised recommendations