<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Incremental Checking of OCL Constraints through SQL Queries</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Xavier Oriol</string-name>
          <email>xoriol@essi.upc.edu</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Ernest Teniente</string-name>
          <email>teniente@essi.upc.edu</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Service and Information System Engineering Universitat Polit`ecnica de Catalunya - BarcelonaTech</institution>
        </aff>
      </contrib-group>
      <fpage>23</fpage>
      <lpage>32</lpage>
      <abstract>
        <p>We propose a new method for efficiently checking OCL constraints by means of SQL queries. That is, an OCL constraint is satisfied if its corresponding SQL query returns the empty set. Such queries are computed in an incremental way since, whenever a change in the data occurs, only the constraints that may be violated because of such change are checked and only the relevant values given by the change are taken into account. Moreover, the queries we generate do not contain nested subqueries nor procedures. In this way, we take advantage of relational DBMS capabilities and we get an efficient check of OCL constraints.</p>
      </abstract>
      <kwd-group>
        <kwd>OCL</kwd>
        <kwd>Constraints Checking</kwd>
        <kwd>SQL</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        A conceptual schema is the description of an Information System in terms of
the data it should contain and the operations available to users to modify such
data [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. To define conceptual schemas, the Object Management Group (OMG)
has defined the UML/OCL standards [
        <xref ref-type="bibr" rid="ref2 ref3">2,3</xref>
        ]. Broadly speaking, UML is used for
specifying a class diagram, i.e. the structure of the data, and OCL for stating
the conditions (i.e. the constraints) that should always be satisfied by the data.
      </p>
      <p>
        We aim at defining an efficient method to perform integrity checking of OCL
constraints. That is, to efficiently check whether the OCL constraints of the
schema are satisfied by the data contents. Such problem arises in several
situations like conceptual schema execution in animation tools (like USE [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]) or
checking whether a model satisfies the constraints defined in its metamodel in
MDA [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. Unfortunately, there are not efficient OCL checkers able to deal with
medium-large scenarios [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ].
      </p>
      <p>
        One way to efficiently check OCL constraints is aimed at reducing such
problem to check the emptiness of some SQL query [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ]. Intuitively, given an OCL
constraint, we can build an SQL query that returns all instances that violate it.
Thus, the OCL constraint is satisfied if and only if the SQL query is empty. In
this way, we benefit from all optimization techniques of current DBMS for query
answering. Moreover, since SQL is widely used for storing data from constrained
domains, bringing an efficient method for checking constraints based on SQL
might be integrated in current industrial systems without crossing technologies.
      </p>
      <p>
        To our knowledge, there are two implemented tools that perform such
translation: OCL2SQL [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] and MySQL4OCL [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. However, their translation should be
further optimized to scale up for efficient integrity checking in large scenarios.
Mainly, because whenever a change in the data occurs (e.g. an insertion of a new
instance), the whole query is recomputed, when it probably just need to check
whether the updated data should appear as a result of the query.
      </p>
      <p>The main goal of this paper is to overcome the previous drawback by
proposing a translation from OCL constraints to SQL queries which allows to compute
them incrementally by a relational DBMS. This is achieved by generating SQL
queries which are only recomputed when the change applied to the data may
violate their associated constraint and such that, whenever the computation is
performed, only the relevant values given by the update are taken into account.
In addition, our generated queries do not nest subqueries nor procedures.</p>
      <p>
        Our method starts by applying the automatic translation of OCL Constraints
into Event Dependency Constraints (EDCs), as defined in [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ]. An EDC is a logic
formula which states when some structural events (i.e. insertions or deletions of
data) may cause the violation of a constraint. In terms of logics, an EDC is a
conjunctive query with negated base atoms and built-in literals (i.e. arithmetic
comparisons). So, an EDC has the form: l1 ∧ ... ∧ ln ∧ bil1 ∧ ... ∧ bilm → ⊥,
where each li is a literal representing an instance, an instance insertion or an
instance deletion; and bilj is a built-in literal. For example, the EDC: user(X) ∧
ιuserAge(X, Age) ∧ Age &lt; 18 → ⊥ states that a constraint is violated if there
is a user X in the data and we insert some Age below 18 to this user X.
      </p>
      <p>From this point, we define an inductive translation from EDCs to SQL.
Broadly speaking, l1 gives the initial table to start the FROM clause, then,
each li is joined with the other tables by a cross join (i.e. a Cartesian product),
inner join or anti join depending on the binding of the variables of li and its
positive/negative sign. Any bilj is directly placed in the WHERE clause.</p>
      <p>Literals li representing an instance insertion or deletion, i.e. a change taking
place over the data, provide the key for incrementality. Each such li is translated
as an SQL join from a table containing such insertions/deletions to the rest of
tables translated from the other EDC literals. When a user wants to apply an
update, this update is first inserted in the auxiliary tables and, once the method
has ensured that it does not cause any integrity constraint violation, the update
is applied to the real tables and the auxiliary tables are emptied. Such process
may be automatized by means of a DB controller.</p>
      <p>Since each SQL query contains at least one of such literals, such query
computations will always be tied to the data changes. For instance, in the previous
EDC, ιuserAge(X, Age) joins the query with the insertion of an age to a user.
Thus, if we do not insert any age for any user, the join will return the empty
set and no more evaluation will be needed. On the contrary, if there is some
insertion of an age to a user, the join will retrieve only the affected user(s) from
which to continue the query computation. Note that such evaluation is better
than retrieving all the users of the database and then perform the convenient
checks for each one for any kind of data update.</p>
      <p>As a result, we get some SQL queries that are empty if and only if the OCL
constraints are satisfied. Such queries perform incrementally and, in addition,
avoid the use of nested queries/procedures. As a trade-off, the expressiveness of
OCL is limited to the fragment of OCL translatable to EDCs.</p>
      <p>To show the benefits of our method, we have performed some experiments to
compare the efficiency of our translation with the translations given by OCL2SQL
and MySQL4OCL. In such empirical study, we show that whereas our approach
is capable to check the integrity of a set of constraints in at most 3 seconds per
constraint regarding scenarios with 5·106 instances and 5·104 updates, OCL2SQL
and MySQL4OCL could not check some invariants after one hour of execution.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Related Work</title>
      <p>
        To our knowledge, there are two tools implementing an OCL to SQL
translation: OCL2SQL[
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] and MySQL4OCL[
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. We review both of them separately. In
addition, we review the research on incremental OCL integrity checking, some
work based on translating OCL to graph patterns, and some other based on
translating FOL based constraints to incremental SQL queries.
      </p>
      <p>
        OCL2SQL. OCL2SQL is a component of the OCL Dresden Toolkit for
translating OCL constraints to SQL views [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. The idea is that such SQL views are
empty if and only if all the constraints are satisfied. The bases for such
translation were early established in [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], however, since such bases were not defined
inductively, it is hard to realize which OCL subset does it deal with. In any case,
the main drawback that we find in it is the non-incrementality of their checks.
MySQL4OCL. MySQL4OCL is a tool for translating OCL expressions to
MySQL queries [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. The translation is tied to MySQL because it uses some
procedures for translating iterator expressions of OCL (e.g. forAll, exists, select,
etc). In this way, they deal with a broad subset of OCL. Moreover, they can
also deal with the three valuated logic of OCL (i.e. true, false, null). However,
and similarly to OCL2SQL, the translation of the constraints is not incremental
and thus, we do not know which queries should be recomputed and which is the
relevant data to take into account to check the data integrity after some update.
      </p>
      <sec id="sec-2-1">
        <title>Incremental OCL Integrity Checking. There are already some proposals on</title>
        <p>
          how to incrementally check OCL constraints [
          <xref ref-type="bibr" rid="ref11 ref12 ref13">11,12,13</xref>
          ]. Applying such methods
it is possible to realize which constraints should be checked and which is the
relevant data to analyse after some data updates. Nevertheless, as far as we
know, none of them have been adapted to work with databases on its behind.
OCL translation to graph patterns. The work of [
          <xref ref-type="bibr" rid="ref5">5</xref>
          ] consists in translating
OCL constraints into graph patterns to benefit from its incremental capabilities.
Such proposal relies on the intensive usage of memory since it is not intended to
work with databases, but from data kept in memory. To overcome such difficulty,
in [
          <xref ref-type="bibr" rid="ref14">14</xref>
          ] there is a proposal implementing the incremental graph patterns approach
using some distributed databases. However, it seems that such databases are just
implementing the persistence and the data is still kept (and queried) in memory.
FOL to incremental SQL queries. Decker proposed a method to translate
constraints specified in a logic notation (different from OCL) into incremental
SQL queries [
          <xref ref-type="bibr" rid="ref15">15</xref>
          ]. In his proposal, constraints are translated into queries that
are invoked by triggers when a change over the data may cause a violation of
a constraint. This is the way efficiency is achieved. However, and despite the
difference on the language used to specify the constraints, we are not aware of
any implementation of this approach that allow us to compare its efficiency with
ours in the experiments we have performed.
3
        </p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Translating OCL Constraints to SQL Queries</title>
      <p>In the following, we first define a conceptual schema with some OCL constraints
that will be used as a running example to illustrate our method. Then, we show
the representation of the OCL constraints in the form of EDCs. Such EDCs
adds the incrementality capabilities to constraint checking. Finally, we give an
inductive translation from such EDCs to SQL queries to perform the incremental
checks of the constraints by means of relational DBMS technology.
3.1</p>
      <sec id="sec-3-1">
        <title>An Illustrative Example</title>
        <p>Consider the example in Fig. 1 of a message service application. In this class
diagram, a user sends messages to some conversation groups. There are two
kinds of conversation groups: pairs, that is, two simple users sending messages
to each other; and groups, that is, two or more users formally grouped since
some creation date. As expected, a group has some users as members and also
one user as owner.</p>
        <p>ConversationGroup receiver
1</p>
        <p>IsSentToP
{disjoint,Pcomplete}P</p>
        <p>Pair
0..,</p>
        <p>IsFormedByP
2
creatioGnrToimupe:PDate o00gw..r..o,,nuepMdOewmnbeerorwun2se.e.1r,r lspathasottCen:eoUP:nPSsnSeteritrcnritgn:PgDate s1enderSends m0s..g, cbroedayMt:i0oPe.nS.,sTtrsiimnmagegs:egPDate</p>
        <p>OCL Constraints in Fig. 2 states some constraints that should always be
satisfied by the data of such schema. Concretely, MessagesInAPairBelongToPair
and MessagesInAGroupBelongToGroup state that the messages received by any
pair/group are sent by the members of such pair/group.
UserIsMemberOfOwnedGroups states that the owner of a group is also a member of such group and
finally, MessagesOfGroupAreSentAfterItsCreation states that any messages sent
to a group has to be created after the creation of the group.</p>
        <p>Note that we have deliberately omitted the identifier constraints of the classes
(e.g. User.allInstances()-&gt;isUnique(phone)) because they can be easily well
treated by SQL primary keys on tables.</p>
        <p>context Pair inv MessagesInAPairBelongToPair:
self.user-&gt;includesAll(self.msg.sender)
context Group inv MessagesInAGroupBelongToGroup:
self.user-&gt;includesAll(self.msg.sender)
context User inv UserIsMemberOfOwnedGroups:
self.group-&gt;includesAll(self.owned)
context Group inv MessagesOfGroupAreSentAfterItsCreation:
self.msg-&gt;forAll(e|e.creationTime &gt; self.creationTime)</p>
        <p>
          Given a translation of the UML class diagram into SQL tables, our goal is
to translate each OCL constraint into an SQL query in such a way that the
constraint is not violated by an update (i.e. a change over the data) if and only
if its corresponding SQL query is empty. For this purpose, we will first represent
the violations of OCL constraints by means of EDCs and, then, obtain the SQL
queries from this intermediate representation.
The starting point of our work is the Event-Dependency Constraints (EDC)
representation of the OCL constraint violations. The translation from OCL to
EDCs can be fully automatized using the method described in [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ]. For the sake
of self-containment we review the formal notion of EDC below.
        </p>
        <p>An EDC is a logic formula that states when some structural events (i.e.
insertions or deletions of data) may cause the violation of a constraint. In terms
of logics, an EDC is a conjunctive query with negated base atoms and
builtin literals (i.e. arithmetic comparisons). That is, it has the form l1 ∧ ... ∧ ln ∧
bil1 ∧ ... ∧ bilm → ⊥ where each li is a literal representing either an instance, an
instance insertion or an instance deletion; and bilj is a built-in literal. Such
builtin-literals are optional. In addition, EDCs are safe clauses, that is, any variable
appearing in a negated or built-in literal, also appears in a positive literal.</p>
        <p>For instance, the EDCs representation of the UserIsMemberOfOwnedGroups
OCL constraint is:
¬owner(G, U ), ιowner(G, U ), ¬member(G, U ), ¬ιmember(G, U ) → ⊥
¬owner(G, U ), ιowner(G, U ), member(G, U ), δmember(G, U ) → ⊥
owner(G, U ), ¬δowner(G, U ), member(G, U ), δmember(G, U ) → ⊥
(1)
(2)
(3)</p>
        <p>Note that an OCL constraint is written into more than one EDC since each
EDC defines a different combination of events that may lead to the violation
of the constraint. Concretely, Rule 1 above states that
UserIsMemberOfOwnedGroups will be violated if we insert a user U as the owner of group G, where
U is not a member of G and without inserting U as a member of G. Rule 2
identifies a violation of the same constraint when we insert U as the owner of G
while deleting U as a member of G. Finally, Rule 3 indicates a violation when
we delete U as a member of G without deleting U as the owner of G.</p>
        <p>
          The length of an EDC is directly proportional to the length of the OCL
constraint, but the number of EDC rules we get for an OCL constraint is
exponential to the number of navigation steps of it since there is an exponential
number of different ways to violate a constraint and each EDC captures one. To
avoid such situation, we could take out the common factor of EDCs (e.g. rules
2 and 3 could be summarized in one rule using disjunctions). In this way, we
would achieve a behavior similar to the TREAT algorithm [
          <xref ref-type="bibr" rid="ref16">16</xref>
          ] where joins are
performed using the union between a table and its new insertions. However, in
TREAT, each constraint is evaluated as many times as tables containing new
instances are accessed in the definition of the constraint. The efficiency
comparison of our proposal and TREAT is left out for further work since, as far as we
know, there is no tool implementing TREAT in SQL for OCL constraints.
        </p>
        <p>
          It is worth saying that the current translation from OCL to EDCs only deals
with a fragment of OCL. However, such fragment is expressive enough to deal
with a superset of the constraints that can be specified with the constraint
patterns defined in [
          <xref ref-type="bibr" rid="ref17">17</xref>
          ], which have been shown to be useful for defining around
the 60% of the integrity constraints found in real schemas. The grammar of the
OCL constraints translatable into EDCs can be found in [
          <xref ref-type="bibr" rid="ref10">10</xref>
          ].
3.3
        </p>
      </sec>
      <sec id="sec-3-2">
        <title>From the UML Class Diagram to SQL Tables</title>
        <p>Before translating the EDCs into SQL queries, we need to translate the UML
class diagram into SQL tables. In our example, we will suppose that each UML
class/association has been translated into a different SQL table. Thus, the
signatures of the tables obtained from the class diagram of Fig. 1 are the following:</p>
        <sec id="sec-3-2-1">
          <title>Pair(id) ConversationGroup(id) Group(id,creationTime)</title>
        </sec>
        <sec id="sec-3-2-2">
          <title>Owner(user, group) Member(user, group) User(id,phone,state,lastConnect)</title>
        </sec>
        <sec id="sec-3-2-3">
          <title>Sends(user, message) Message(id, body, time) IsSentTo(conversgroup,message)</title>
        </sec>
        <sec id="sec-3-2-4">
          <title>IsFormedBy(pair,user)</title>
          <p>3.4</p>
        </sec>
      </sec>
      <sec id="sec-3-3">
        <title>Translating EDCs to SQL Queries</title>
        <p>We define now an inductive translation from EDCs to SQL queries based on the
EDC length. The translation is composed by two functions: one for computing
the from clause and another for computing the where clause. Regarding the select
clause, we select the column that represents the id of the instances violating the
constraint (i.e. the self OCL instances for which the invariant evaluates to false).</p>
        <p>Therefore, the translation of an EDC to an SQL query is given by the pattern:</p>
        <sec id="sec-3-3-1">
          <title>SELECT sqlColumn(edcVariable(”self ”))</title>
        </sec>
        <sec id="sec-3-3-2">
          <title>FROM fromTransl(EDC)</title>
        </sec>
        <sec id="sec-3-3-3">
          <title>WHERE whereTransl(EDC)</title>
          <p>Where sqlColumn returns the SQL column name corresponding to the given
EDC variable. The EDC variable in which we are interested is the one
corresponding to the OCL self variable, so, we use the function edcVariable with the
parameter ”self” to obtain it. In case that there is no ”self” variable in the OCL
constraint (e.g. the constraint may be like Class.allInstances()-&gt;forAll(e|...)),
other options should be considered like selecting the column/s corresponding to
the OCL iterator variable/s (e.g. the previous e variable).</p>
          <p>Since EDCs use some literals to represent the insertion/deletion of instances,
we assume that our database schema contains also some public auxiliary tables
in which we temporally store the instances that are being inserted/deleted. Thus,
such literals are mapped to those auxiliary tables.</p>
          <p>For instance, EDC 2 uses the literal ιowner. Such literal is mapped to a
new auxiliary SQL table ins owner where we temporary write the insertions of
instances of owner we are applying to the data.</p>
          <p>Finally, recall that an EDC has the form l1 ∧ ... ∧ ln ∧ bil1 ∧ ... ∧ bilm → ⊥.
Without loss of generality, we assume that all negated literals are placed in the
end of the formula (i.e. from some li to ln); and that all terms of a literal lj are
variables with different names. Such condition can be ensured by replacing some
terms for new fresh variables and binding such variables to its actual terms with
new built-in literals (e.g. P(X,1) would be translated to P(X,Y) ∧ Y = 1 ).
Translation Base Case In the base case, the EDC is composed by just one
literal l1. Such literal is necessarily positive to ensure the safeness of the clause.
Then, the translation is as follows:
fromTransl(l1) = sqlTable(l1)
whereTransl(l1) = ∅
Translation Inductive Case In the inductive case, the EDC has the form
L ∧ li or L ∧ bili, where L is a non-empty list of literals, li is a positive or negated
literal, and bili a built-in literal.</p>
          <p>In the first case, if li is positive, the translation consists in an inner join
between the translations of li and L joining the columns corresponding to their
bound variables. If no variable is bound, then, a cross join (i.e., a Cartesian
product) is performed instead. Thus, the translation is as follows:
fromTransl(L ∧ li) = fromTransl(L) JOIN sqlTable(li) ON (binding(L, li))
whereT ransl(L ∧ li) = whereT ransl(L)</p>
          <p>Where binding(L, li) is a function that returns the column joins according to
the variables of li that are bound to L.</p>
          <p>If li is negative, the translation consists in performing an anti join to get
those tuples of L that do not join li. For performing the anti join, we use a left
join and check the joined columns to be null. Thus, the translation results in:
fromTransl(L ∧ li) = fromTransl(L) LEFT JOIN sqlTable(li) ON (binding(L, li))
whereT ransl(L ∧ li) = whereT ransl(L) AND columnN ame(li, 1) IS NULL</p>
          <p>Where columnName(li, 1) returns the name of the first SQL column of the
SQL table corresponding to li. Such column is used to check whether the joined
columns resulted into null.</p>
          <p>Also, notice that binding(L, li) will not be empty because all the variables of
li are necessarily bound to L since any EDC satisfies the safeness property.</p>
          <p>Finally, the translation when we deal with a built-in literal bili is as follows:
fromTransl(L ∧ bili) = fromTransl(L)
whereT ransl(L ∧ bili) = whereT ransl(L) AND sqlComparison(L, bili)
Where sqlComparison is a function that translates the bili into the SQL
syntax. I.e. it changes the variables of bili for the corresponding SQL column
names of the L variables they are bound to. Note that all variables of bili are
bound to L because the safeness property.</p>
          <p>Translation example To illustrate our translation, we show how the EDC in
rule 2 is specified as an SQL query. First of all, we sort the EDC literals to move
the negated ones to the end of the formula, thus obtaining the following EDC’:
ιowner(G, U ), member(G, U ), δmember(G, U )¬owner(G, U ) → ⊥</p>
          <p>Next, by applying the translation we have just defined, we get:
SELECT T0.user
FROM ins_owner AS T0
WHERE T3.group IS NULL</p>
          <p>JOIN Member AS T1 ON (T1.group = T0.group AND T1.user = T0.user)
JOIN del_Member AS T2 ON (T2.group = T0.group AND T2.user = T0.user)
LEFT JOIN Group AS T3 ON (T3.group = T0.group AND T3.group = T0.group)
Lastly, and since violations of an OCL constraint are specified by means of
several EDCs, the final SQL query we obtain to check the OCL constraint is
given by the SQL union of all the queries we have obtained from each EDC.
4</p>
        </sec>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>Experiments</title>
      <p>
        We have conducted an experiment to illustrate the scalability improvement
provided by our SQL queries as compared to OCL2SQL[
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] and MySQL4OCL[
        <xref ref-type="bibr" rid="ref9">9</xref>
        ]. In
this experiment, we show that we can scale up to scenarios with 5*106 instances
with 5·104 updates to check a set of OCL constraints whereas OCL2SQL and
MySQL4OCL can not deal with some of them after 1 hour of execution. Since
the time required to check a constraint is independent from the others, we stayed
at a reduced number of constraints without altering the relevance of our results.
      </p>
      <p>Given the schema of a message service application in our example, the
conducted experiment consisted into adding some new message instances to some
conversation groups in several randomly generated database states of increasing
size. Then, we checked all the constraints of the example by means of the queries
generated by MySQL4OCL, OCL2SQL and our incremental approach.</p>
      <p>The randomly generated data consisted in N users who randomly had already
sent N ∗ 10 messages distributed in N/10 groups and N/10 pairs. The update
consisted in N/10 new messages. The experiments were carried out on MySQL
5.6 running on Windows 7 in a Intel T4500 2.30GHz machine with 4GB of RAM.
The database had the MySQL default indexes for primary/foreign keys.</p>
      <p>We show our results in table 1. The title of the columns indicates the size
of the database giving the number of current preexisting messages. As it can
be seen, we are able able to check the integrity of the constraints in at most
3 seconds per constraint with a database state with 5·106 messages and 5·104
new insertions. In contrast, OCL2SQL/MySQL4OCL cannot afford some of the
constraints after 1 hour of execution.</p>
      <p>The result of the 3rd constraint requires to take special attention. Since
adding new messages cannot cause the violation of the 3rd OCL constraint
(UserIsMemberOfOwnedGroups ), our incremental approach performs in almost
constant time because the query begins from an empty auxiliary table. For the
other approaches, we argue that its better performance might be because it
contains one level less of subqueries in comparison to the other constraints.</p>
    </sec>
    <sec id="sec-5">
      <title>5 Conclusions</title>
      <p>We have proposed a method for efficiently checking OCL constraints by means of
SQL queries that perform incrementally since only the relevant constraints and
the relevant values are taken into account during the computation. In addition,
they are written in such a way not to nest any other query nor procedure inside.</p>
      <p>To achieve it, we first specify the OCL constraint violations through an EDC
formalism. Such formalism offers the advantage of stating which events may
cause the violation of an integrity constraint. Then, each EDC is translated into
an SQL query. When doing such translation, we create some new SQL tables for
temporary storing the new instances that are going to be inserted/deleted. Such
auxiliary tables are used by our SQL queries to perform incrementally.</p>
      <p>
        We made some experiments showing that our approach is able to check in
seconds four OCL constraints over an scenario containing 5·106 instances with
5·104 updates while other approaches like OCL2SQL and MySQL4OCL could
not afford some of these constraints after 1 hour of execution. As future work, we
would like to extend the fragment of OCL we are dealing with and to implement
in SQL the rules proposed in [
        <xref ref-type="bibr" rid="ref16">16</xref>
        ] to compare the efficiency achieved in this case.
Acknowledgements This work has been partly supported by the Ministerio de
Ciencia e Innovacio´n under project TIN2011-24747 and by the FI grant from the Secreteria
d’Universitats i Recerca of the Generalitat de Catalunya. We would like also to thank
the anonymous reviewers for their comments.
      </p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1. Oliv´e, A.:
          <source>Conceptual Modeling of Information Systems</source>
          . Springer, Berlin (
          <year>2007</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>Object</given-names>
            <surname>Management Group (OMG): Unified Modeling Language (UML) Superstructure</surname>
          </string-name>
          <string-name>
            <surname>Specification</surname>
          </string-name>
          <source>, version 2.4.1</source>
          . (
          <year>2011</year>
          ) http://www.omg.org/spec/UML/.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>Object</given-names>
            <surname>Management</surname>
          </string-name>
          <article-title>Group (OMG): Object Constraint Language (UML), version 2</article-title>
          .4. (
          <year>2014</year>
          ) http://www.omg.org/spec/OCL/.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4. Hamann, L.,
          <string-name>
            <surname>Hofrichter</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Gogolla</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>On integrating structure and behavior modeling with OCL</article-title>
          .
          <source>In: International Conference on Model Driven Engineering Languages &amp; Systems (MODELS</source>
          <year>2012</year>
          ), Springer (
          <year>2012</year>
          )
          <fpage>235</fpage>
          -
          <lpage>251</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Bergmann</surname>
          </string-name>
          , G.:
          <article-title>Translating OCL to graph patterns</article-title>
          .
          <source>In: Model-Driven Engineering Languages and Systems. Volume 8767 of LNCS</source>
          . Springer (
          <year>2014</year>
          )
          <fpage>670</fpage>
          -
          <lpage>686</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Clavel</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Marina</surname>
            ,
            <given-names>E.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Miguel Angel</surname>
          </string-name>
          , G.d.D.:
          <article-title>Building an efficient component for OCL evaluation</article-title>
          .
          <source>Electronic Communications of the EASST</source>
          <volume>15</volume>
          (
          <year>2008</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Demuth</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hussmann</surname>
          </string-name>
          , H.:
          <article-title>Using UML/OCL constraints for relational database design</article-title>
          .
          <source>In: UML99 - The Unified Modeling Language</source>
          . Springer (
          <year>1999</year>
          )
          <fpage>598</fpage>
          -
          <lpage>613</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Demuth</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Wilke</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>Model and object verification by using Dresden OCL</article-title>
          .
          <source>In: Proceedings of the Russian-German Workshop “Innovation Information Technologies: theory and practice”</source>
          ,
          <source>Russia</source>
          . (
          <year>2009</year>
          )
          <fpage>81</fpage>
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <surname>Egea</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Dania</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Clavel</surname>
            ,
            <given-names>M.:</given-names>
          </string-name>
          <article-title>MySQL4OCL: A stored procedure-based MySQL code generator for OCL</article-title>
          .
          <source>Electronic Communications of the EASST</source>
          <volume>36</volume>
          (
          <year>2010</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          10.
          <string-name>
            <surname>Oriol</surname>
            ,
            <given-names>X.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Tort</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Teniente</surname>
          </string-name>
          , E.:
          <article-title>Fixing up non-executable operations in UML/OCL conceptual schemas</article-title>
          . In:
          <string-name>
            <surname>Conceptual</surname>
            <given-names>Modeling-ER</given-names>
          </string-name>
          <year>2014</year>
          .
          <article-title>(</article-title>
          <year>2014</year>
          )
          <fpage>232</fpage>
          -
          <lpage>245</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          11.
          <string-name>
            <surname>Uhl</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Goldschmidt</surname>
            ,
            <given-names>T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Holzleitner</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          :
          <article-title>Using an OCL impact analysis algorithm for view-based textual modelling</article-title>
          .
          <source>ECEASST</source>
          <volume>44</volume>
          (
          <year>2011</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          12.
          <string-name>
            <surname>Groher</surname>
            ,
            <given-names>I.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Reder</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Egyed</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>Incremental consistency checking of dynamic constraints</article-title>
          . In: Fundamental Approaches to Software Engineering. Springer (
          <year>2010</year>
          )
          <fpage>203</fpage>
          -
          <lpage>217</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          13.
          <string-name>
            <surname>Cabot</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Teniente</surname>
          </string-name>
          , E.:
          <article-title>Incremental integrity checking of UML/OCL conceptual schemas</article-title>
          .
          <source>Journal of Systems and Software</source>
          <volume>82</volume>
          (
          <issue>9</issue>
          ) (
          <year>2009</year>
          )
          <fpage>1459</fpage>
          -
          <lpage>1478</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          14. Sza´rnyas, G., Izso´,
          <string-name>
            <surname>B.</surname>
          </string-name>
          ,
          <source>Ra´th, I.,</source>
          <string-name>
            <surname>Harmath</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bergmann</surname>
            ,
            <given-names>G.</given-names>
          </string-name>
          , Varro´, D.:
          <article-title>IncQueryD: A distributed incremental model query framework in the cloud</article-title>
          .
          <source>In: ModelDriven Engineering Languages and Systems. Volume 8767 of LNCS</source>
          . Springer (
          <year>2014</year>
          )
          <fpage>653</fpage>
          -
          <lpage>669</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref15">
        <mixed-citation>
          15.
          <string-name>
            <surname>Decker</surname>
          </string-name>
          , H.:
          <article-title>Translating advanced integrity checking technology to SQL</article-title>
          . In: Database Integrity. (
          <year>2002</year>
          )
          <fpage>203</fpage>
          -
          <lpage>249</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref16">
        <mixed-citation>
          16.
          <string-name>
            <surname>Miranker</surname>
            ,
            <given-names>D.P.:</given-names>
          </string-name>
          <article-title>TREAT: A better match algorithm for AI production systems</article-title>
          .
          <source>In: Proc. of the 6th National Conf. on Artificial Intelligence</source>
          . Volume 1 of AAAI., AAAI Press (
          <year>1987</year>
          )
          <fpage>42</fpage>
          -
          <lpage>47</lpage>
        </mixed-citation>
      </ref>
      <ref id="ref17">
        <mixed-citation>
          17.
          <string-name>
            <surname>Costal</surname>
            ,
            <given-names>D.</given-names>
          </string-name>
          , Go´mez,
          <string-name>
            <given-names>C.</given-names>
            ,
            <surname>Queralt</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            , Ravento´s, R.,
            <surname>Teniente</surname>
          </string-name>
          , E.:
          <article-title>Improving the definition of general constraints in UML</article-title>
          .
          <source>Software &amp; Systems Modeling</source>
          <volume>7</volume>
          (
          <issue>4</issue>
          ) (
          <year>2008</year>
          )
          <fpage>469</fpage>
          -
          <lpage>486</lpage>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>