<!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>ER4ML: An ER Modeling Tool to Represent Data Transformations in Data Science</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Dihia Lanasri</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Carlos Ordonez</string-name>
          <xref ref-type="aff" rid="aff2">2</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Ladjel Bellatreche</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Selma Khouri</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Query</string-name>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Machine</string-name>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>ESI</institution>
          ,
          <addr-line>Algiers</addr-line>
          ,
          <country country="DZ">Algeria</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>LIAS/ISAE-ENSMA</institution>
          ,
          <addr-line>Poitiers</addr-line>
          ,
          <country country="FR">France</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>University of Houston</institution>
          ,
          <country country="US">USA</country>
        </aff>
      </contrib-group>
      <fpage>123</fpage>
      <lpage>127</lpage>
      <abstract>
        <p>Transforming several relational tables into a data set to be used as input to a Machine Learning (ML) model is a complex task since the data scientist has to derive many intermediate tables, queries and views in a disorganized manner. This process creates many SQL queries to facilitate the exploration task of the data scientist. Because the provenance of the intermediate results is not re ected, similar SQL queries tend to be written multiple times causing repeated manual work. In this paper, we propose a tool "ER4ML" assisting data scientists in modeling and visualizing the transformations applied to the relational database before obtaining a dataset feeding the ML models. ER4ML is a diagram ow based on a conceptual view of the database schema and transformations based on powerful extensions of ER diagram in UML notations. In addition, ER4ML tracks data provenance, improving query and data set reuse.</p>
      </abstract>
      <kwd-group>
        <kwd>ER diagram Learning</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1 Introduction</title>
      <p>In order to feed their de ned Machine Learning (ML) models, data scientists
collect, clean, aggregate and transform important amounts of relational data
to elaborate a tabular dataset with many features. Pre-processing relational
datasets is a complex process consuming more than 80 % of the project time.This
Pre-processing needs to execute di erent SQL queries in a disorganized manner
outside the DBMS, without thinking to model the entity-relationship(ER)
modi cations. These transfromations result in several intermediate temporary tables
or views,that are not modeled in the ER diagram. These transformations are
valuable knowledge for future analytics reusing similar sets of entities. However,
reusing them presents a challenge for data scientists because of the lack of a
modeling and GUI tools helping them to understand what has been performed
and the intermediate results of SQL queries that construct the ML model. We
defend the idea of creating an extended ER model to understand such a set of
disconnected tables and views at a high level.</p>
      <p>
        To overcome this issue, we propose a tool "ER4ML" aiming to assist data
scientists to visualize and understand the di erent transformations using
complex SQL queries (including joins, selections, projections, aggregations and the
powerful CASE statement), applied to the relational dataset given as an input
to an ML model. ER4ML is based on a de ned model "Extended ER" detailed
in [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ] proposing minimal but powerful extensions to an ER diagram as a
conceptual ow representation. It helps to understand a chain of transformations
basing on SQL queries going from the physical level(tables) to the logical level
(entities), in UML notations. The importance of SQL queries to transform
relational data to build a data set for ML is identi ed in [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. ER4ML provides a
graphical web interface that shows the transformations applied to the ER model
and the provenance of each attribute (primary or foreign keys and non-key) with
a coloring code to distinguish between source and transformation entities. The
transformation entities can be of two main types: denormalization or
aggregation, while the nal dataset is the result of outer joins (denormalization) tending
to create non-3NF tables. Our system shares some similarities with data reverse
engineering and ETL tools, but they have many di erences[
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. We establish a
connection with existing ER diagrams, instead of building a separate diagram.
      </p>
      <p>This paper is organized as follows: Section 2 discusses the related work.
Section 3 presents the architecture of our tool and details its main modules. Section
4 presents our demonstration scenario and Section 5 concludes our paper.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Related Work</title>
      <p>
        Based on reverse engineering processes for extracting the database conceptual
model from its physical model, some studies de ned conceptual view of relational
datasets[
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] or extending ER modeling by de ning some schema transformations[
        <xref ref-type="bibr" rid="ref6">6</xref>
        ];
or data warehouse conceptual model by classi cation on mining models[
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. Our
paper focuses on a unique extended ER diagram that uni es the physical and
conceptual levels. Other solutions propose to model the ETL/ELT processes at a
conceptual level[
        <xref ref-type="bibr" rid="ref3">3</xref>
        ] basing on the BPMN model[
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. Our solution represents data
processing with transformation entity boxes and SQL queries.
3
      </p>
    </sec>
    <sec id="sec-3">
      <title>Research Application Contribution</title>
      <p>3.1. Extended ER model for Data Transformation: The proposed tool
is based on the Extended ER model that de nes a database as D(T ; I), where
T = fT1; : : : ; Tng, is a set of n tables and I is a set of integrity constraints (entity
for primary key (PK), referential for foreign key (FK)), and represents the chain
of transformations as a conceptual ow diagram. We use the term "table" to
make a connection to the physical level and SQL querying. SQL queries can be
classi ed into either aggregation or denormalization transformation. We assume
well formed queries are used to create datasets, which include a PK to identify
rows and at least one non-key attribute.
3.2. Layered System Architecture: Figure 3 illustrates the architecture of
our system which is designed following the 3-tiers architecture based on the MVC
paradigm covering three layers:
Presentation layer: is the GUI presented to the user for visualizing the database
schema, the di erent transformations and the used SQL queries. The system
distinguishes between source and transformation entities. The type of each entity
is indicated in its name (eg. Source:EntityName, Denormalization:Ti and
Aggregation:Tj ). The nal obtained dataset is named "Dataset:Tx" where (i,j,x)
are sequence numbers. Our diagram ow is automatically generated based on
physical model notation complementary to UML notations. Our Extended ER
notation does not change UML notation for ER, instead we show transformation
entities in color green/Red/blue and ER entities in white. The arrows represent
data ow (NOT relationships) but we still link entities (source &amp;
transformation) with FKs/PKs. This layer is developed using HTML, BOOTSTRAP, CSS,
JavaScript (JS), and GOJS library used to build interactive ER diagrams where
the user can hide or show selectively the transformation entities.
Functional Logic layer: is the core of our solution. It contains three main
modules of the system: Model extraction, ER initialization, and Transformation
modules responsible for generating an extended ER model for each dataset to
be given to an ML model. (i) Model extraction module: generates an ER model
from a relational data source using a speci c DBMS connector. Our solution deals
with any DBMS, but in our demonstration scenario we consider sqlite3 module
for node JS connceting to SQLite DBMS thanks to its simplicity and overhead.
This module extracts the structure of the database (tables, their columns,
constraints and relationships) and generates two JSON les that de ne the model
and that can be read by GOJS library. The rst and the second les contain
respectively the relationships and the entities. (ii) ER initialization module: takes
the two JSON les as input and extracts the detailed structures of nodes and
links to initialize the ER model, to be displayed by the presentation module.
(iii) Transformation module: we assume the user is responsible for specifying
the components and results of each transformation and has the prior knowledge
to distinguish between fact table &amp; analytic dataset and check the validity of
ER models. This module enriches the extended ER model for each new SQL
query by: (a) de ning the transformation type (Aggregation or
Denormalization), (b) de ning the SQL query that generates the intermediate table, the
query is displayed as a comment next to the transformation entity so to zoom
in the transformation applied. (c) creating the transformation entities (named
"TYPE Ti" i is an auto-increment sequence number) that are displayed using
di erent colors. The module also allows: (d) associating the PK, FK &amp; other
attributes to the transformation entity. (e) According to the tables joined in
the From clause of the query, the module identi es the relationships to existing
entities to show the provenance of the transformation entities &amp; their attributes,
using an ARROW link between transformation entities, this allows the user to
folow the chain of transfromations. (f) creating cardinalities of relationships:
one2many and many2one.</p>
      <p>
        Data layer: after each valid transformation step, the new generated extended
ER model is stored as JSON les. The development of this tool is performed
on WebStorm IDE. GitHub is used for the versioning of the project. The source
code of our solution is available on: https://github:com/dihiaselma/ER4ML
In our system demonstration we will show our extended, elegant and intuitive ER
model obtained in a few seconds from typical SQL queries. It helps
understanding complex data transformations. Our demonstration is based on the basketball
dataset containing statistics about players, coaches, and teams in men's
professional basketball leagues from 1937 to 2012, which are extracted from the Open
Source Sports website. We constructed an SQLite database from these les and
proceeded to veri cation of integrity constraints and PK-FK links. We use 14
transformations4 deriving features using some complex Joins, aggregations and
the powerful CASE statement, resulting from the previous work [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ] that include
queries using CASE statement to obtain the last dataset that will be used for
the ML model aiming to predict winning and losing teams. Using our tool, a
user will see the ER model corresponding to the de ned database, displayed as
a dynamic graph. Let us take as an example the rst query that represents
denormalization. The user chooses 'Denormalization' transformation type, speci es
the query and the set of included tables. Then, she speci es the list of attributes,
the cardinalities between entities can also be speci ed. The new diagram that
extends the existing one is generated displaying the rst transformation entity
as shown in gure 2. The new transformation table is in light green, named
"Denormalization T1", next to the SQL query de ned as a comment bull to help the
user understanding the transformation executed. Furthermore, the PK and FK
columns are labeled and the cardinalities are displayed above the arrow link
colored in dark green. In the case of Aggregation, the transformation entities are in
light red while the relationship(arrow) is in dark red. Our tool helps data
scientists re ne data source in multiple iterations by adding, removing and changing
features basing on JOINS and aggregations via the described SQL queries until
obtaining the nal dataset containing o ensive &amp; defensive features.
      </p>
      <p>A detailed demonstration video is available at https://youtu:be/nJkZ8aBa6co
which gives a nice overview of di erent functionalities of our tool. It emphasizes
on following points: (1)ER representation of temporary tables, (2)Flow of a chain
of data transformations, (3)Conceptual separation between aggregation and
de4 https://drive:google:com/file/d/1A29k9wjIfp0QpYgtf8dbooQH3qmbDqy6/view
normalization, (4)Complex SQL queries, (5)Reusing existing queries and tables
and (6)Connected view of data via primary and foreign keys.
5</p>
    </sec>
    <sec id="sec-4">
      <title>Conclusions</title>
      <p>In order to assist data scientists managing and understanding the di erent
transformations applied to a relational database and create a tabular dataset serving
as input to their ML models, we developed a new tool \ER4ML" that
graphically generates an extended ER model based on UML notations. It models all the
intermediate temporary tables or views resulting from SQL queries, as entities
enriching the existing database schema. This tool can be seen as an interesting
response to the major question discussed during the Dagstuhl seminar 18471
titled Next Generation Domain Speci c Conceptual Modeling: Principles and Methods,
in last November regarding the integration of conceptual modeling in ML. Despite this,
our tool presents some limitations: i) The user cannot view the ML model as entities.
ii)The user cannot view data transformations done with external languages like Java,
R or Python. iii) Our tool is good for data represented with tables, not for text or
images. As a perspective, we are extending our tool to deal with datasets issued from
di erent database formats.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Boyd</surname>
            ,
            <given-names>M.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>McBrien</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>Comparing and transforming between data models via an intermediate hypergraph data model</article-title>
          .
          <source>In: JoDS IV</source>
          , pp.
          <volume>69</volume>
          {
          <fpage>109</fpage>
          . Springer (
          <year>2005</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>El</given-names>
            <surname>Akkaoui</surname>
          </string-name>
          ,
          <string-name>
            <given-names>Z.</given-names>
            ,
            <surname>Mazon</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.N.</given-names>
            ,
            <surname>Vaisman</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            ,
            <surname>Zimanyi</surname>
          </string-name>
          , E.:
          <article-title>Bpmn-based conceptual modeling of etl processes</article-title>
          .
          <source>In: DaWaK</source>
          . pp.
          <volume>1</volume>
          {
          <fpage>14</fpage>
          . Springer (
          <year>2012</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Oliveira</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Belo</surname>
            ,
            <given-names>O.</given-names>
          </string-name>
          :
          <article-title>Using reo on etl conceptual modelling: a rst approach</article-title>
          . In: DOLAP. pp.
          <volume>55</volume>
          {
          <fpage>60</fpage>
          .
          <string-name>
            <surname>ACM</surname>
          </string-name>
          (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Ordonez</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          :
          <article-title>Data set preprocessing and transformation in a database system</article-title>
          .
          <source>Intelligent Data Analysis (IDA) 15(4)</source>
          (
          <year>2011</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Ordonez</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bellatreche</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          :
          <article-title>Enhancing ER diagrams to view data transformations computed with queries</article-title>
          .
          <source>In: DOLAP</source>
          (
          <year>2019</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Poulovassilis</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>McBrien</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          :
          <article-title>A general formal framework for schema transformation</article-title>
          .
          <source>DKE</source>
          <volume>28</volume>
          (
          <issue>1</issue>
          ),
          <volume>47</volume>
          {
          <fpage>71</fpage>
          (
          <year>1998</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Shi</surname>
            ,
            <given-names>Z.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Moorthy</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Zimmermann</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          :
          <article-title>Predicting ncaab match outcomes using ml techniques-some results and lessons learned</article-title>
          .
          <source>In: ECML/PKDD</source>
          (
          <year>2013</year>
          )
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Zubco</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Trujillo</surname>
          </string-name>
          , J.:
          <article-title>Conceptual modeling for classi cation mining in data warehouses</article-title>
          .
          <source>In: DaWaK</source>
          . pp.
          <volume>566</volume>
          {
          <fpage>575</fpage>
          . Springer (
          <year>2006</year>
          )
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>