SQL-PL4OCL: An Automatic Code Generator from OCL to SQL Procedural Language

  • Abstract
  • Literature Map
  • Similar Papers
Abstract
Translate article icon Translate Article Star icon

Design models are widely spread as core artifacts in software engineering. Yet, a key problem is how to fulfill correctly these blueprint specifications when code components are developed. The best possible scenario occurs when a source modeling language can be perfectly linked to a target language of election. Namely, a well defined mapping bridges the gap between the source and the target language. Otherwise, manual encoding of the system design is cumbersome and error prone. In this setting, we introduce a SQL-PL1 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. More in detail, our source language is the Object Constraint Language (OCL), which nowadays is an ISO standard used to express constraints and queries in a textual notation on UML models. Our target language is the procedural language (PL) extension to the Structured Query Language (SQL). SQL is a special-purpose programming language designed for managing data in relational database management systems (RDBMS). The purpose of PL for SQL is to combine database language and procedural programming language. Although SQL is also an ISO standard, different RDBMS implement certain syntactic variations to the standard SQL notation. Thus, we had to adapt the implementation of our mapping to each of them. As implementation targets we selected MariaDB, PostgreSQL, and MS SQL Server. MariaDB and PostgreSQL were selected because they are open source and widely used by developers. MS SQL server was selected to be able to compare evaluation time from open source to commercial RDBMS. A variety of applications arises for a mapping from OCL to SQL expressions. Among others, there are three prominent types. These are i) evaluation of OCL expressions (analysis queries and metrics) on large model's instances, ii) identification of constraints during data modeling that have to be checked as integrity constraints on actual data; iii) automatic code generation from models. Indeed, our implementation was used as a key component of a toolkit that automatically generated ready-to-deploy web applications for secure data management from design models. Our component mapped and evaluated OCL constraints specified within authorization policies. Our code generator is defined recursively over the structure of OCL expressions and it is implemented in the SQL-PL4OCL tool that is publicly available at [1]. The seminal work of the mapping presented here can be found in [2], [3]. The key idea that enables the mapping from OCL iterator expressions to iterative stored procedures remains the same, but the work detailed in [4] introduces a novel mapping from OCL expressions to SQL-PL stored procedures. In the novel mapping we have taken design decisions which have facilitated the recursive definition of the code generator and simplified its definition. These decisions have also helped to significantly decrease the time required for the evaluation of the code generated. Regarding semantics, the new mapping is able to deal properly with the three-valued evaluation semantics of OCL. In addition, our original work and implementation was intended only for the procedural extension of MySQL, while our new definition eased the implementation of the mapping into other relational database management systems. In turn, we can now evaluate the resulting code using different RDBMS, which permits us to widen our discussion regarding efficiency in terms of evaluation-time of the code produced by SQL-PL4OCL tool.

Similar Papers
  • Conference Article
  • Cite Count Icon 2
  • 10.1109/coginf.2007.4341922
Using Verbal Protocols to Assess the Influence of Import-Coupling on the Comprehensibility of OCL Expressions
  • Aug 1, 2007
  • Luis Reynoso + 2 more

The import coupling of an object constraint language (OCL) expression increases when the expression operates within a large context of a Unified Modelling Language (UML) model. The expression would thus exhibit a decrease in its comprehensibility, and in consequence, the maintainability of the OCL expressions could be affected, due to the fact that modelers need to know all the artifacts upon which the expression relies. In order to explain the cognitive complexity of modelers dealing with OCL expressions with high import- coupling we have carried out a think aloud experiment which is described in detail in this paper. The experiment is part of a project which we are developing with the goal of obtaining valid measures through which to assess the influence of import coupling on OCL expression maintainability. The empirical results show evidence that: (1) reified objects, problem objects and their relationships constitute the main components of the cognitive complexity of modelers; (2) modelers use different cognitive approaches to comprehend an OCL expression within a UML/OCL model.

  • Research Article
  • Cite Count Icon 10
  • 10.1016/j.infsof.2018.06.010
Object constraint language for code generation from activity models
  • Jul 17, 2018
  • Information and Software Technology
  • E.V Sunitha + 1 more

Object constraint language for code generation from activity models

  • Research Article
  • Cite Count Icon 24
  • 10.1007/s10270-008-0083-2
Semantics of OCL specified with QVT
  • Mar 11, 2008
  • Software & Systems Modeling
  • Slaviša Marković + 1 more

The Object Constraint Language (OCL) has been for many years formalized both in its syntax and semantics in the language standard. While the official definition of OCL’s syntax is already widely accepted and strictly supported by most OCL tools, there is no such agreement on OCL’s semantics, yet. In this paper, we propose an approach based on metamodeling and model transformations for formalizing the semantics of OCL. Similarly to OCL’s official semantics, our semantics formalizes the semantic domain of OCL, i.e. the possible values to which OCL expressions can evaluate, by a metamodel. Contrary to OCL’s official semantics, the evaluation of OCL expressions is formalized in our approach by model transformations written in QVT. Thanks to the chosen format, our semantics definition for OCL can be automatically transformed into a tool, which evaluates OCL expressions in a given context. Our work on the formalization of OCL’s semantics resulted also in the identification and better understanding of important semantic concepts, on which OCL relies. These insights are of great help when OCL has to be tailored as a constraint language of a given DSL. We show on an example, how the semantics of OCL has to be redefined in order to become a constraint language in a database domain.

  • Research Article
  • 10.31645/jisrc.23.21.1.9
Test Case Design Of Security Threats Through State Machine OCL
  • Jun 7, 2023
  • Journal of Independent Studies and Research Computing
  • Asif Raza + 2 more

Software testing is one activity for Software Quality Assurance (SQA). One way to test is through Black box test cases at design level. Since UML is a de-facto design language and is one of the most used design language now a day. Therefore, there is need to design black box test cases using UML behavioral diagrams. Object Constraint Language (OCL) is a formal language to write constraints on UML diagrams as it is unambiguous. Although test cases against robustness have been designed through OCL expressions but no test cases as yet have been designed against security specific authentication, access control and availability. Specification and testing of security specific authentication, access Control and availability through OCL. An experiment is performed with a hypothesis ‘if Security Specific Authentication, Access Control and Availability is specified through OCL in state diagram then Test cases can be designed’. We have specifiedsecurity in OCL then same OCL expressions are used to model security in UML state diagram. Furthermore, mutation testing is performed on OCL expressions. Then ECP is done using same extracted mutants. Security specific authentication, access control and availability is specified in OCL and then test cases are designed using a black box testing technique Equivalence Class Partitioning. Hypothesis results shows that one can design test cases through OCL. This thesis shows that Specification and Testing of Security specific authentication, access control and availability through OCL.

  • Book Chapter
  • Cite Count Icon 22
  • 10.1007/978-3-540-75209-7_6
An Empirical Study of the Impact of OCL Smells and Refactorings on the Understandability of OCL Specifications
  • Sep 11, 2007
  • Alexandre Correa + 2 more

The Object Constraint Language (OCL) is a OMG standard that plays an important role in the elaboration of precise models. However, it is not hard to find models and metamodels containing overly complex OCL expressions. Refactoring is a technique that can be used in this context since its goal is to reduce complexity by incrementally improving the internal software quality. Indeed several refactorings have already been proposed to improve the quality of OCL expressions. This paper presents the results of an empirical study that investigates the impact of poor OCL constructs, also known as OCL Smells, and OCL refactorings on the understandability of OCL expressions. Current results show that most refactorings significantly improve the understandability of OCL specifications.

  • Research Article
  • Cite Count Icon 38
  • 10.1007/s10270-003-0026-x
Formal semantics of static and temporal state-oriented OCL constraints
  • Oct 1, 2003
  • Software & Systems Modeling
  • Stephan Flake + 1 more

The textual Object Constraint Language (OCL) is primarily intended to specify restrictions over UML class diagrams, in particular class invariants, operation pre-, and postconditions. Based on several improvements in the definition of the language concepts in last years, a proposal for a new version of OCL has recently been published [43]. That document provides an extensive OCL semantic description that constitutes a tight integration into UML. However, OCL still lacks a semantic integration of UML Statecharts, although it can already be used to refer to states in OCL expressions. This article presents an approach that closes this gap and introduces a formal semantics for such integration through a mathematical model. It also presents the definition of a temporal OCL extension by means of a UML Profile based on the metamodel of the latest OCL proposal. Our OCL extension enables modelers to specify behavioral state-oriented real-time constraints. It provides an intuitive understanding and readability at application level since common OCL syntax and concepts are preserved. A well-defined formal semantics is given through the mapping of temporal OCL expressions to temporal logics formulae.

  • Book Chapter
  • Cite Count Icon 5
  • 10.1007/978-3-319-74730-9_31
Step 0: An Idea for Automatic OCL Benchmark Generation
  • Jan 1, 2018
  • Hao Wu

Model Driven Engineering (MDE) is an important software development paradigm. Within this paradigm, models and constraints are essential components for expressing specifications of a software artefact. Object Constraint Language (OCL), a specification language that allows users to freely express constraints over different model features. However, one major issue is that the lack of OCL benchmarks makes difficult to evaluate existing and newly created OCL tools. In this paper, we present our initial idea about automatic OCL benchmark generation. The purpose of this paper is to show a developing idea rather than presenting a more formal and complete approach. Our idea is to use an OCL metamodel to sketch abstract syntax trees for OCL expressions, and solve generated typing constraints to produce the concrete OCL expressions. We illustrate this idea by using an example, discuss our work-in-progress and outline challenges to be tackled in the future.

  • Conference Article
  • Cite Count Icon 3
  • 10.1145/3183440.3194976
CrossEcore
  • May 27, 2018
  • Simon Schwichtenberg + 3 more

Today, model-driven approaches are a cornerstone in modern software development. The Eclipse Modeling Framework (EMF) is highly adopted in practice and generates Java code from platform-independent models with embedded Object Constraint Language (OCL) expressions. However, applications that target multiple platforms like Android, iOS, Windows, web browsers usually need to be implemented in different programming languages. Feature-complete Ecore and OCL runtime APIs are not available for all these platforms, such that their functionality has to be re-implemented. In this paper, we present CrossEcore: A multi-platform enabled modeling framework that generates C#, Swift, TypeScript, and JavaScript code from Ecore models with embedded OCL. An OCL compiler translates OCL expressions into expressions of the target language. The Ecore and OCL API can be consistently used across platforms, which facilitates application portability. CrossEcore is also extendible and can be easily adopted for new programming languages.

  • Book Chapter
  • Cite Count Icon 6
  • 10.1007/978-3-030-35653-8_13
OCL2PSQL: An OCL-to-SQL Code-Generator for Model-Driven Engineering
  • Jan 1, 2019
  • Hoang Nguyen Phuoc Bao + 1 more

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.

  • Research Article
  • Cite Count Icon 15
  • 10.1007/s10270-017-0597-6
SQL-PL4OCL: an automatic code generator from OCL to SQL procedural language
  • May 4, 2017
  • Software & Systems Modeling
  • Marina Egea + 1 more

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.

  • Research Article
  • 10.61643/c79757
SCHQL (Structure Chinese Query Language): A SQL Parser for Bridging Language Gaps in SQL Environments
  • Sep 18, 2025
  • The Pinnacle: A Journal by Scholar-Practitioners
  • Bruce Mills + 1 more

This methodological paper introduces a Structured Chinese Query Language (SCHQL), an author-designed SQL parser/translator for enhancing the accessibility and usability of Relational Database Management Systems (RDBMS) for Chinese language users by facilitating the translation of SQL (structured query language) keywords into Chinese. The PHP language is used as front-end to the RDBMS (relational database management system) enabling users to perform Create, Read, Update, and Delete (CRUD) operations directly within the browser’s query editor using Chinese characters replacing English key-words shown in the keyword pairs array of the script. While no participants were involved in this study, the parser has the potential to alleviate cognitive load, making database interactions more intuitive for non-English (Chinese) speakers. Cognitive load is not researched here, however it is discussed and referenced. The parser has been tested, with results demonstrated in the figures presented. This paper details the development, implementation, and evaluation of SCHQL, underscoring its potential to bridge the language gap in RDBMS interaction, not just in Chinese language domain but other language pairs as well. Future research is open to user testing to assess the tool's effectiveness and usability across diverse languages, potentially contributing to global SQL accessibility. This project is compliant with the Inclusive Language Guide (American Psychological Association, n.d.).

  • Conference Article
  • Cite Count Icon 4
  • 10.1109/icimt.2009.55
An Adaptive Algorithms Translating and Back-Translating of Object Constraint Language into Structure Query Language
  • Jan 1, 2009
  • Nutchanat Siripornpanit + 1 more

This paper aims to develop the algorithms to translate and back-translate the OCL (Object Constraint Language) into SQL (Structure Query Language). The translation will use word substring and word comparing. The OCL or SQL to word substring and word compare the algorithm. To consider a table name, relation name and conditions can be set the three sections into language model and showed the result to the users. It can help reducing time and errors of the translation. Moreover, it increases convenience for the users to translate and back-translate of OCL constraints to SQL expressions.

  • Conference Article
  • Cite Count Icon 3
  • 10.1109/isspit.2007.4457995
OCL Expressions and their Context: Transformation Rules for the Semantic Integration of OCL and RSL
  • Dec 1, 2007
  • N Debnath + 5 more

A set of rules to integrate Object Constraint Language (OCL) and the RALSE Specification Language (RSL) are shown and discussed. The rules presented here cover the translation of OCL expressions to semantically equivalent RSL expressions. The proposed rules here complete our previous work where we showed how to derive an initial formal specification in RSL from a UML class diagram, illustrated the use of RSL and OCL integration via an example, and proposed a complementary subset of rules for the translation of types and operations. We also present here a brief explanation of previous work on which the transformation rules are based.

  • Research Article
  • Cite Count Icon 18
  • 10.14279/tuj.eceasst.44.670.685
Using an OCL Impact Analysis Algorithm for View-Based Textual Modelling
  • Oct 20, 2011
  • Technische Universität Berlin – Universitätsbibliothek
  • Axel Uhl + 2 more

The Object Constraint Language (OCL) has become a vital part of many frameworks, tools and languages within model-driven engineering. One such application of OCL is the use for describing rules in concrete syntax definitions. Within the textual modeling framework FURCAS, OCL is extensively used for the definition of lookup and attribution rules. Based on these rules the model which is described by such a textual representation is created and updated accordingly. Changes on models over which such an expression is specified require the expression to be re-evaluated to keep the constructed model up-to-date. However, the effort for re-evaluating OCL expressions over a set of model elements grows with the number of elements, the complexity of the expressions, and the number of model changes. Thus, having large models and/or complex expressions places considerable performance costs on OCL evaluation. Techniques to reduce this effort have been presented in previous work but do not cover the full range of OCL expressions, in particular calls to operations defined in OCL, including recursive operations. In this paper, we present an approach that is applicable to the full range of OCL expressions. We validated our approach based on a large set of models and complex expressions to evaluate the performance impact of our newly introduced techniques.

  • Conference Article
  • Cite Count Icon 7
  • 10.1109/eit.2007.4374543
Integrating OCL expressions into RSL specifications
  • May 1, 2007
  • Narayan Debnath + 5 more

In this work, we go a step further in the integration of the RAISE specification language (RSL) and the unified modeling language (UML). On the basis of our previous work -where we showed how to derive an initial formal specification in RSL from a UML class diagram-we propose here the use of set of rules to transform object constraint language (OCL) expressions into RSL expressions. Class diagrams can be enhanced with annotated OCL invariants and the corresponding formalizations in RSL can be obtained. Property verification of the model described by the UML class diagram and OCL invariants can now take place on the derived RSL specification by using reasoning techniques supported by the RAISE method.

Save Icon
Up Arrow
Open/Close
Notes

Save Important notes in documents

Highlight text to save as a note, or write notes directly

You can also access these Documents in Paperpal, our AI writing tool

Powered by our AI Writing Assistant