Transformation of OntoUML to SQL written in Smalltalk.
= Moco
Moco{empty}footnote:moco[Moco is an acronym for “model converter”.] is a library that implements automated transformations of OntoUML model to SQL and https://alloytools.org/[Alloy].
== Features
=== OntoUML to SQL
The library can transform any valid OntoUML model into a SQL script that instantiates an empty database, which can store data described by the conceptual model. All constraints implied by the OntoUML model are transformed to database triggers to ensure data consistency.
The transformation is executed in three stages:
1. **OntoUML to UML.** All class and relationship stereotypes are supported, supports optimization of phases, roles, relators and generalization sets.
2. **UML to RDB.** Classes, attributes, associations, generalizations, generalization sets and enumerations are supported.
3. **RDB to SQL.** Tables, columns, primary, unique, foreign keys and derived OCL constraints are supported.
Moco supports PostgreSQL, Oracle, Microsoft SQL Server and MySQL as the target relational database platform.
=== OntoUML to Alloy
The library generates an Alloy specification from any valid OntoUML model, which can be used to verify that the model is instantiable and to generate example instances in the https://alloytools.org/download.html[Alloy Analyzer].
The modal aspects of OntoUML are verified by using instances of a `World` signature that correspond to different points in the life-time of the model (https://lib.jucs.org/article/29828/[Benevides, 2010]).
To succesfully execute the verification, the transformed Alloy specification must be placed into a skeleton. Additionally, the World Structure and Ontological Properties modules must be available. All three artifacts are attached in the `docs/alloy` directory in this repository.
== Usage
This library is primarily intended to be used as a plugin to https://openponk.org/[OpenPonk] — a modeling tool that supports OntoUML. A prebuilt distribution of OpenPonk that includes Moco is available at https://gitlab.fit.cvut.cz/jaburjak/openponk-moco[gitlab.fit.cvut.cz/jaburjak/openponk-moco].
The transformation can be invoked by menu _Diagram_ » _Moco_ » _Transform to SQL_ (or Alloy).
image::docs/readme_files/openponk-1.png[]
image::docs/readme_files/openponk-2.png[]
image::docs/readme_files/openponk-3.png[]
For the SQL transformation, the target platform (PostgreSQL, Oracle, MSSQL or MySQL) can be selected in the Settings Browser.
=== Manual Installation
You can use Metacello to load the library, as shown below. Moco can be used even outside OpenPonk; in that case, you won’t be able to use the `Moco-OpenPonk` package.
[source,smalltalk]
----
Metacello new baseline: 'Moco';
repository: 'github://jaburjak/moco:main';
load.
----
Currently, https://github.com/OpenPonk/class-editor/releases/tag/v4.1.3[OpenPonk 4.1.3] and Pharo 12 are supported.
== License
Created by Jakub Jabůrek, released under the MIT License. Please see the https://github.com/jaburjak/moco/blob/main/LICENSE[LICENSE] file for more information.
== Acknowledgements
* The approach for the transformation of OntoUML to Oracle SQL was developed by Dr. Zdeněk Rybola in his Ph.D. thesis __Towards OntoUML for Software Engineering: Transformation of OntoUML into Relational Databases__ (2017).
* The approach for the transformation of OntoUML to Alloy was developed by Dr. Tiago P. Sales in their Ph.D. thesis __Ontology Validation for Managers__ (2014).