UNIVERSIDADE FEDERAL DO RIO GRANDE DO SUL INSTITUTO DE INFORMÁTICA PROGRAMA DE PÓS-GRADUAÇÃO EM COMPUTAÇÃO ALEXANDRE TORRES Essential Notation for Object-Relational Mapping Thesis presented in partial fulfillment of the requirements for the degree of Doctor in Computer Science. Prof. Dr. Renata Galante Adviser Prof. Dr. Marcelo S. Pimenta Co-adviser Porto Alegre, Abril, 2014. CIP – CATALOGAÇÃO NA PUBLICAÇÃO Torres, Alexandre Essential Notation for Object-Relational Mapping / Alexandre Torres. – 2014. 188 f.:il. Orientadora: Renata Galante. Co-orientador: Marcelo Pimenta. Tese (Doutorado) – Universidade Federal do Rio Grande do Sul, Instituto de Informática, Programa de Pós-Graduação em Computação. Porto Alegre, BR – RS, 2014. 1. Object-Relational Mapping. 2. Model-Driven Development. 3. Patterns. 4. UML. 5. Relational Model. I. Galante, Renata, orient. II. Pimenta, Marcelo, coorient. III. Título. UNIVERSIDADE FEDERAL DO RIO GRANDE DO SUL Reitor: Prof. Carlos Alexandre Netto Vice-Reitor: Prof. Rui Vicente Oppermann Pró-Reitor de Pós-Graduação: Prof. Vladimir Pinheiro do Nascimento Diretor do Instituto de Informática: Prof. Luís da Cunha Lamb Coordenador do PPGC: Prof. Luigi Carro Bibliotecária-Chefe do Instituto de Informática: Beatriz Regina Bastos Haro Essential Notation for Object-Relational Mapping ABSTRACT This thesis presents the Essential Notation for Object-Relational Mapping (ENORM), a general purpose notation that represents structural concepts of Object- Relational Mapping (ORM). The goal of ENORM is to facilitate the design by the clear application of ORM patterns, document mappings with a platform independent notation, and became a repository for model-driven transformations, partial code generation, and round-trip engineering tools. ENORM is a UML profile based notation, designed to represent patterns within a domain modeling logic, with objects of the domain incorporating both behavior and data. The notation represents patterns adopted by widespread ORM frameworks in the market (Active Record, of Ruby; SQLAlchemy, of Python; Entity Framework, of Microsoft .net; JPA, Cayenne, and MyBatis, of Java), following the Don´t Repeat Yourself and Convention over Configuration principles. ENORM was evaluated by controlled experiments, comparing the modeling by students with the use of separated UML and relational models, achieving significantly more goals in the majority of the scenarios, without being significantly different in the worst experimental scenarios. Keywords: Object-Relational Mapping, Model-Driven Development, Patterns, UML, Relational Model. RESUMO Esta tese apresenta a Notação Essencial para Mapeamento Objeto-Relacional (em inglês, ENORM), uma notação de propósito geral que representa os conceitos estruturais do Mapeamento Objeto-Relacional (MOR). O objetivo de ENORM é facilitar o projeto através da aplicação clara dos padrões MOR, documentação dos mapeamentos com uma notação independente de plataforma, e tornar-se um repositório para transformações dirigidas por modelos, geração parcial de código e ferramentas de engenharia round-trip. ENORM é uma notação baseada em perfil UML, projetada para representar padrões pertencentes a lógica de modelo do domínio, com objetos do domínio incorporando tanto comportamento como dados. A notação representa padrões adotados por frameworks MOR difundidos no mercado (Active Record, do Ruby; SQLAlchemy, do Python; Entity Framework, da Microsoft .net; JPA, Cayenne, and MyBatis, do Java), seguindo os princípios Não se repita e Convenção sobre Configuração. ENORM foi avaliado por experimentos controlados, comparando a modelagem de estudantes com modelos UML e relacionais separados, atingindo um número significativamente maior de objetivos na maioria dos cenários, sem ser significativamente diferente nos piores cenários experimentais. Palavras-chave: Mapeamento Objeto-Relacional, Desenvolvimento Dirigido por Modelos, Padrões, UML, Modelo Relacional. LIST OF ABBREVIATIONS ANOVA Analysis of Variance AST Abstract Syntax Tree BNF Backus–Naur Form CoC Convention over Configuration DA Data Administrator DRY Do not Repeat Yourself principle EBNF Extended Backus–Naur Form EER Extended Entity-Relationship ER Entity-Relationship FK Foreign Key IMP Impedance Mismatch Problem JPA Java Persistence API MDD Model-Driven Development OO Object-Oriented ORM Object-Relational Mapping PIM Platform Independent Model PK Primary Key PSI Platform Specific Information PSM Platform Specific Model RAR Ruby´s Active Record RDB Relational Data Base Rel Relational model SA SQLAlchemy SoC Separation of Concerns UML Unified Modeling Language LIST OF FIGURES FIGURE 1.1: TEXT ORGANIZATION................................................................19 FIGURE 2.1: JAVA EXAMPLES OF TABLE MODULE PATTERN (LEFT) AND DOMAIN MODEL PATTERN (RIGHT)..............................................................21 FIGURE 2.2: ACTIVE RECORD EXAMPLE......................................................23 FIGURE 2.3: INHERITANCE TO GENERATED CLASSES.............................24 FIGURE 2.4: INSTANTIATED MAPPING EXAMPLE FOR SQLALCHEMY LOOSE COUPLING APPROACH......................................................................24 FIGURE 2.5: JPA LOOSE COUPLING OVERVIEW.........................................25 FIGURE 2.6: DATA MAPPER SUCH AS IN MYBATIS....................................27 FIGURE 2.7: ENTITY DATA MODEL FOR MS ENTITY FRAMEWORK (SNEED, 2012)...................................................................................................29 FIGURE 2.8: CAYENNE MODELS DOMAIN AND DATABASE ELEMENTS SEPARATED......................................................................................................30 FIGURE 2.9: PRIMARY KEY FIELDS (A) AND PRIMARY KEY CLASS (B).. 31 FIGURE 2.10: ASSOCIATION RELATIONSHIP BETWEEN CLASSES..........33 FIGURE 2.11: ASSOCIATION TABLE EXAMPLE...........................................36 FIGURE 2.12: UML MODEL (LEFT) AND TABLES (RIGHT) OF THE ASSOCIATION TABLE EXAMPLE...................................................................37 FIGURE 2.13: DEPENDENT MAPPING PATTERN EXAMPLE: CLASS MODEL (UPPER) AND DATABASE MODEL (LOWER)..................................38 FIGURE 2.14: INHERITANCE EXAMPLE FOR ACCOUNT.............................40 FIGURE 2.15: SINGLE-TABLE APPROACH FOR ACCOUNT EXAMPLE.....40 FIGURE 2.16: CLASS-TABLE APPROACH FOR ACCOUNT EXAMPLE......40 FIGURE 2.17: CONCRETE-TABLE APPROACH FOR ACCOUNT EXAMPLE. ............................................................................................................................41 FIGURE 2.18: INDEPENDENT KEYS IN CLASS-TABLE INHERITANCE EXAMPLE...........................................................................................................42 FIGURE 3.1: MAIN VISUAL ELEMENTS AND THEIR MEANING...................47 FIGURE 3.2: SIMPLE TRANSACTION EXAMPLE...........................................48 FIGURE 3.3: SUMMARY ACCOUNT EXAMPLE..............................................48 FIGURE 3.4: DATABASE MODEL OF ACCOUNT EXAMPLE........................49 FIGURE 3.5: MAIN ELEMENTS OF THE ENORM PROFILE...........................51 FIGURE 3.6: A CLASS EMBEDDED BY TWO PERSISTENT CLASSES.......54 FIGURE 3.7: EMBEDDED CLASSES REFERENCING PERSISTENT CLASSES...........................................................................................................55 FIGURE 3.8: TRANSITIVITY OF EMBEDMENT...............................................55 FIGURE 3.9: USING <<EMBED>> FOR DEPENDENT MAPPING..................56 FIGURE 3.10: TWO COLLECTION-EMBEDMENTS EXAMPLE.....................57 FIGURE 3.11: TWO DEPENDENT COLLECTIONS TO THE SAME CLASS.. 57 FIGURE 3.12: MAP WITH KEY REFERENCE..................................................58 FIGURE 3.13: THREE DIFFERENT INHERITANCE EXAMPLES WITHOUT PARENT TABLE................................................................................................58 FIGURE 3.14: INHERITED ASSOCIATION WITH PERSISTENT CLASS.......59 FIGURE 3.15: ALTERNATIVE WAY TO EXPRESS MAPPED SPECIALIZATIONS WITH ENORM...................................................................59 FIGURE 3.16: ENORM PROFILE MODEL OF GENERATORS.......................60 FIGURE 3.17: PROFILE MODEL OF TABLE DEFINITIONS, FOR INDEXES AND CONSTRAINTS.........................................................................................60 FIGURE 3.18: DEFINITION EXAMPLE WITH UNIQUE INDEX CONSTRAINT DEFINITION........................................................................................................61 FIGURE 3.19: A SKETCH OF META-MODEL WITH FLEXIBLE DATA SOURCES..........................................................................................................62 FIGURE 3.20: TEMPLATE PARAMETER EXAMPLE......................................63 FIGURE 3.21: EBNF SPECIFICATION FOR ENORM LABELS......................64 FIGURE 3.22: VISUAL DISTRIBUTION OF THE ENORM NON-TERMINALS. ............................................................................................................................65 FIGURE 3.23: MODELING TOOL SCREEN SHOT..........................................66 FIGURE 3.24: EXPERIMENTAL TOOL ARCHITECTURE...............................67 FIGURE 3.25: MDD SCENARIO FOR ENORM MODELS................................67 FIGURE 3.26: UML PROFILE FOR DATA MODELING EXAMPLE (AMBLER, HARTFORD AND RUECKERT, 2003)..............................................................69 FIGURE 4.1: PARTY PATTERN DESIGNED WITH ENORM...........................72 FIGURE 4.2: ACCOUNTABILITY, FIRST MODEL...........................................78
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages188 Page
-
File Size-