Skip to main content

OCL2PSQL: An OCL-to-SQL Code-Generator for Model-Driven Engineering

  • Conference paper
  • First Online:
Future Data and Security Engineering (FDSE 2019)

Part of the book series: Lecture Notes in Computer Science ((LNISA,volume 11814))

Included in the following conference series:

Abstract

The Object Constraint Language (OCL) is a textual, declarative language typically used as part of the UML standard for specifying constraints and queries on models. Several attempts have been proposed in the past for translating OCL expressions into SQL queries in the context of Model Driven Engineering (MDE). To cope with OCL expressions that include iterators, previous attempts resorted to imperative features (loops, cursors) of SQL, with the consequent loss of efficiency. In this paper, we define (and implement) a novel mapping from OCL to SQL that covers (possibly nested) iterators, without resorting to imperative, non-declarative features of SQL. We show with a preliminary benchmark that our mapping generates SQL queries that can be efficiently executed on mid- and large-size SQL databases.

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Notice that we do not include in our language operations on collections of collections, nor we support the value. Since SQL does not natively support (parametrized) structured collections, mappings from OCL to SQL would need to explicitly encode this “structure” in the generated queries, as proposed in [8]. Similarly, since SQL does not natively support the invalid value, mappings from OCL to SQL would have to handle this value in “ad hoc” ways. Currently, none of the other mappings is able to support (parametrized) structured collections or the value.

  2. 2.

    At the time of writing, our tool temporarily uses an OCL parser that requires adding contextual information to the OCL expressions to be input. Please, check the latest information about this issue in our tool’s web site.

  3. 3.

    SQL engines have highly optimized strategies for executing queries over large databases. Our OCL2PSQL mapping follows some of the well-known optimization “tips” for SQL engines. Nevertheless, we should be aware that “development [for SQL engines] is ongoing, so no optimization tip is reliable for the long term.” (MySQL 8.0 Reference Manual, (13.2.11.11 Optimizing Subqueries).

  4. 4.

    Although we have used MySQL for running our examples, we believe that our overall results should apply likewise to the other SQL engines.

  5. 5.

    The experiment was carried out on a machine with Intel Pentium M 2.00 GHz 600 MHz, and 1 GB of RAM.

References

  1. Baar, T., Markovic, S.: The RoclET tool (2007). http://www.roclet.org/index.php

  2. Basin, D.A., Clavel, M., Egea, M., de Dios, M.A.G., Dania, C.: A model-driven methodology for developing secure data-management applications. IEEE Trans. Softw. Eng. 40(4), 324–337 (2014)

    Article  Google Scholar 

  3. Chiorean, D., Bortes, M., Corutiu, D., Botiza, C., Carcu, A.: An OCL environment (OCLE) 2.0.4 (2005). Laboratorul de Cercetare in Informatica, University of BABES-BOLYAI. http://lci.cs.ubbcluj.ro/ocle/

  4. Clavel, M., Egea, M., de Dios, M.A.G.: Building an efficient component for OCL evaluation. ECEASST 15 (2008)

    Google Scholar 

  5. de Dios, M.A.G., Dania, C., Basin, D., Clavel, M.: Model-driven development of a secure eHealth application. In: Heisel, M., Joosen, W., Lopez, J., Martinelli, F. (eds.) Engineering Secure Future Internet Services and Systems. LNCS, vol. 8431, pp. 97–118. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-07452-8_4

    Chapter  Google Scholar 

  6. Demuth, B., Hussmann, H.: Using UML/OCL constraints for relational database design. In: France, R., Rumpe, B. (eds.) UML 1999. LNCS, vol. 1723, pp. 598–613. Springer, Heidelberg (1999). https://doi.org/10.1007/3-540-46852-8_42

    Chapter  Google Scholar 

  7. Egea, M., Dania, C.: SQL-PL4OCL: an automatic code generator from OCL to SQL procedural language. Softw. Syst. Model. 18, 769–791 (2017)

    Article  Google Scholar 

  8. Egea, M., Dania, C., Clavel, M.: MySQL4OCL: a stored procedure-based MySQL code generator for OCL. ECEASST 36 (2010)

    Google Scholar 

  9. Gogolla, M., Büttner, F., Richters, M.: USE: A UML-based specification environment for validating UML and OCL. Sci. Comput. Program. 69, 27–34 (2007)

    Article  MathSciNet  Google Scholar 

  10. Heidenreich, F., Wende, C., Demuth, B.: A framework for generating query language code from OCL invariants. ECEASST 9 (2008)

    Google Scholar 

  11. Object Management Group. Object constraint language specification version 2.4. Technical report, OMG, February 2014. https://www.omg.org/spec/OCL/About-OCL/

  12. Object Management Group. Unified Modeling Language. Technical report, OMG, December 2017. https://www.omg.org/spec/UML/About-UML/

  13. Oriol, X., Teniente, E.: Incremental checking of OCL constraints through SQL queries. In: Brucker, A.D., Dania, C., Georg, G., Gogolla, M., (eds.) OCL@MoDELS, volume 1285 of CEUR Workshop Proceedings, pp. 23–32. CEUR-WS.org (2014)

    Google Scholar 

  14. ISO/IEC 9075-(1–10) Information technology - Database languages - SQL. Technical report, International Organization for Standardization (2011). http://www.iso.org/iso

Download references

Acknowledgments

This work has been supported by the Vietnamese-German University (VGU-PSSG grant 14/01 - 11/06/2019).

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Hoang Nguyen Phuoc Bao .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2019 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Nguyen Phuoc Bao, H., Clavel, M. (2019). OCL2PSQL: An OCL-to-SQL Code-Generator for Model-Driven Engineering. In: Dang, T., Küng, J., Takizawa, M., Bui, S. (eds) Future Data and Security Engineering. FDSE 2019. Lecture Notes in Computer Science(), vol 11814. Springer, Cham. https://doi.org/10.1007/978-3-030-35653-8_13

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-35653-8_13

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-35652-1

  • Online ISBN: 978-3-030-35653-8

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics