(An Example for) Metamodeling Syntax and Semantics of Two Languages, their Transformation, and a Correctness Criterion

Similar documents
Metamodeling the Entity Relationship and Relational Data Model and their Transformation. Martin Gogolla

Experimenting with Multi-Level Models in a Two-Level Modeling Tool

SLIDES: Introductory Modeling Example Employing UML and OCL [UML: Unified Modeling Language, OCL:Object Constarint Language]

On Squeezing M0, M1, M2, and M3 into a Single Object Diagram

Towards Transformation of Integrity Constraints and Database States

Checking UML and OCL Model Behavior with Filmstripping and Classifying Terms

Metamodeling. Janos Sztipanovits ISIS, Vanderbilt University

Models in Conflict Towards a Semantically Enhanced Version Control System for Models

Object-Oriented Theories for Model Driven Architecture

Teaching Model Views with UML and OCL

Capturing and Formalizing SAF Availability Management Framework Configuration Requirements

Thomas Bleier, Zhendong Ma, Christian Wagner AIT Austrian Insitute of Technology

model-driven development Separation of Concerns in Model-Driven Development

Employing UML and OCL for Designing and Analyzing Role-Based Access Control

Executing Models: Enhancing Validation by Filmstrip Templates and Transformation Alternatives

Software Language Engineering of Architectural Viewpoints

elements of a relation are called tuples. Every tuple represents an entity or a relationship. Country name code population area...

2.2 Relational Model (RM)

MEMOCenterNG A full-featured modeling environment for organization modeling and model-driven software development

Structuring the First Steps of Requirements Elicitation

Metamodeling with Metamodels. Using. UML/MOF including OCL

Model Driven Engineering (MDE)

Annotation for the Semantic Web During Website Development

Part II Black-Box Composition Systems 20. Finding UML Business Components in a Component-Based Development Process

TIME-BASED CONSTRAINTS IN THE OBJECT CONSTRAINT LANGUAGE OCL

UML is still inconsistent!

Towards Generating Domain-Specific Model Editors with Complex Editing Commands

i* on ADOxx : A Case Study

13 AutoFocus 3 - A Scientific Tool Prototype for Model-Based Development of Component-Based, Reactive, Distributed Systems

Exploiting Visual Languages Generation and UML Meta Modeling to Construct Meta-CASE Workbenches

Computing the Relevant Instances that May Violate an OCL constraint

Generating UML diagrams from LEM

Language engineering and Domain Specific Languages

Chapter 8: Enhanced ER Model

2 nd UML 2 Semantics Symposium: Formal Semantics for UML

OCL Support in MOF Repositories

The Unified Modelling Language. Example Diagrams. Notation vs. Methodology. UML and Meta Modelling

Plan. Language engineering and Domain Specific Languages. Language designer defines syntax. How to define language

USE 4 EIS. Martin Gogolla. University of Bremen

CONSTRAINT SPECIFICATIONS USING PATTERNS IN OCL

Electronic Communications of the EASST Volume 44 (2011) Proceedings of the Workshop on OCL and Textual Modelling (OCL 2011)

Developing Web-Based Applications Using Model Driven Architecture and Domain Specific Languages

10.1 Big Objects, Business Objects, and UML Components

Verbalizing Business Rules: Part 9

USE: A UML-Based Specification Environment for Validating UML and OCL

The Role of Metamodeling in MDA

VISO: A Shared, Formal Knowledge Base as a Foundation for Semi-automatic InfoVis Systems

An Ontological Analysis of Metamodeling Languages

A UML 2 Profile for Variability Models and their Dependency to Business Processes

Proceedings of the MoDELS 05 Workshop on Tool Support for OCL and Related Formalisms - Needs and Trends

SeMFIS: A Tool for Managing Semantic Conceptual Models

Chapter (4) Enhanced Entity-Relationship and Object Modeling

Model Transformation Testing Challenges

Automation of Semantic Web based Digital Library using Unified Modeling Language Minal Bhise 1 1

course: Database Systems (NDBI025) SS2017/18

2 Data Reduction Techniques The granularity of reducible information is one of the main criteria for classifying the reduction techniques. While the t

Program Abstractions, Language Paradigms. CS152. Chris Pollett. Aug. 27, 2008.

Meta-Modeling and Modeling Languages

Database Management System Dr. S. Srinath Department of Computer Science & Engineering Indian Institute of Technology, Madras Lecture No.

Computation Independent Model (CIM): Platform Independent Model (PIM): Platform Specific Model (PSM): Implementation Specific Model (ISM):

Draft version. Model Integration with Model Weaving: a Case Study in System Architecture

EMF Refactor: Specification and Application of Model Refactorings within the Eclipse Modeling Framework

Models versus Ontologies - What's the Difference and where does it Matter?

Chapter 8 The Enhanced Entity- Relationship (EER) Model

Towards Two-Level Formal Modeling of Computer-Based Systems

A l Ain University Of Science and Technology

Design and Prototypical Implementation of a Pivot Model as Exchange Format for Models and Metamodels in a QVT/OCL Development Environment

Using High-Level Conceptual Data Models for Database Design A Sample Database Application Entity Types, Entity Sets, Attributes, and Keys

Report on the Aachen OCL Meeting

Pattern Recognition Using Graph Theory

ModelElement. AssociationEnd. Relationship 2. Association. Class. GeneralizableElement. ModelElement

Coherently Explaining UML Statechart and Collaboration Diagrams by Graph Transformations

Context-Aware Analytics in MOM Applications

How useful is the UML profile SPT without Semantics? 1

Fausto Giunchiglia and Mattia Fumagalli

Interoperability in GIS Enabling Technologies

Software Architecture

Feedback from OASIS UBL TC to Draft Core Components Specification 1.8

First Steps Towards Conceptual Schema Testing

Runtime Models as Interfaces for Adapting Software Systems

Toward a Test-Ready Meta-model for Use Cases

Web Services Annotation and Reasoning

Part II Black-Box Composition Systems 10. Business Components in a Component-Based Development Process

Sangam: A Framework for Modeling Heterogeneous Database Transformations

CPS122 Lecture: From Python to Java last revised January 4, Objectives:

March 2, Homepage:

2.2 Syntax Definition

Inference in Hierarchical Multidimensional Space

Static Safety Analysis of UML Action Semantics for Critical Systems Development

Computer Science Applications to Cultural Heritage. Relational Databases

Advanced Topics in Software Engineering (02265) Ekkart Kindler

Towards an integrated graph-based semantics for UML

A Lightweight Language for Software Product Lines Architecture Description

Seminar: Specification and Verification of Object-oriented Software. The KeY Tool

Ontology Refinement and Evaluation based on is-a Hierarchy Similarity

Visual Layout of Graph-Like Models

A Metamodel-Based OCL-Compiler for UML and MOF

A Metamodel for Specifying Quality Models in Model- Driven Engineering

MERGING BUSINESS VOCABULARIES AND RULES

Algebraic Semantics of EMOF/OCL Metamodels

Transcription:

(An Example for) Metamodeling Syntax and Semantics of Two Languages, their Transformation, and a Correctness Criterion Martin Gogolla University of Bremen, Computer Science Department Database Systems Group, D-28334 Bremen, Germany gogolla@informatik.uni-bremen.de Abstract. We study a metamodel for the Entity Relationship (ER) and the Relational data model. We do this by describing the syntax of the ER data model by introducing classes for ER schemata, entities, and relationships. We also describe the semantics of the ER data model by introducing classes for ER states, instances, and links. The connection between syntax and semantics is established by associations explaining that syntactical objects are interpreted by corresponding semantical objects. Analogously we do this for the Relational data model. Finally, we give a metamodel for the transformation of ER schemata into Relational database schemata. By characterizing the syntax and semantics of the languages to be transformed and also the transformation itself within the same (meta-)modeling language we are able to include equivalence criteria on the syntactical and on the semantical level for the transformation. In particular, we show that the semantical equivalence criterion requires that the ER states and the corresponding Relational states bear the same information. Context This paper is based on a comprehensive case study employing our tool USE allowing to check and to reason about properties of UML class diagrams and OCL constraints. The complete model currently covers 7 classes, 34 associations, and 58 constraints. This work uses ideas from earlier material on metamodeling an Extended Entity-Relationship approach [Gog94,Gog95], preliminary versions [GLRZ02] of the metamodel introduced here, and work concentrating only on syntactical aspects [LGR0,GL03]. Dagstuhl Seminar Proceedings 040 http://drops.dagstuhl.de/opus/volltexte/2005/4

M. Gogolla Entity..* 0.. ErSchema Relend 2..* Attribute..* 0.. RelSchema..* RelDBSchema ErState..*..* Relship 0.. Instance Link 0.. 2..* 0.. RelendMap DataType Value AttrMap..* 0.. Tuple 0....* RelDBState 0.. Fig.. Class Diagram Metamodeling the ER and Relational Data Model 2

Metamodeling Syntax and Semantics 2 Metamodeling Data Models Consider the class diagram in Fig.. It shows four clouds : In the left part a solid grey and a solid black cloud, in the right part a dashed grey and a dashed black cloud. The two solid left clouds model the syntax of the data models, the two dashed right clouds the semantics; the upper clouds describe the ER data model, the lower clouds the Relational data model. The ER and the Relational data model share some concepts, namely the parts in the middle talking about data types, attributes and their semantics. Syntax of the ER data model: This part introduces the clases ErSchema, Entity, Relship, Relend, Attribute, and DataType. ErSchema objects consist of Entity and Relship objects which in turn may possess Attribute objects typed through DataType objects. Relend objects represent the connection points between the Relship objects and the Entity objects. Semantics of the ER data model: In this part we set up the classes ErState, Instance, Link, RelendMap, AttrMap, and Value. The interpretation is as follows. An ErSchema object is interpreted by possibly many ErState objects. An Entity is given semantics by a set of Instance objects, and a Relship by a set of Link objects. DataType objects are given life through a set of Value objects. Relend and Attribute objects are interpreted by a set of RelendMap objects and AttrMap object, respectively. In order to give more visual clues for differentiating, the associations from the syntax into the semantics are displayed by bent lines whereas the associations within the syntax and the associations within the semantics are displayed by straight lines. Syntax of the Relational data model: Here the classes RelDBSchema, Rel- Schema, Attribute, and DataType are needed. RelDBSchema objects consist of RelSchema objects which possess Attribute objects typed through Data- Type objects. Semantics of the Relational data model: The last part utilizes the classes RelDBState, Tuple, AttrMap, and Value. RelDBSchema objects are interpreted by a set of RelDBState objects. Each RelDBState object consists of a set of Tuple objects. Tuple objects in turn consist of a set of AttrMap objects assigning a Value object to an Attribute within the Tuple. Let us shortly mention the attributes and operations relevant for the class diagram but being not displayed. All classes in the (left) syntax part possess an attribute name of data type String. The class Attribute has an aditional booleanvalued attribute iskey indicating whether this attribute contributes to the key of the Entity or the RelSchema. The class Value owns the attribute content of data type String indicating the actual content of the Value object. Concerning operations, the classes Instance, Link, and Tuple have an operation applyattr with a State and an Attribute parameter returning the actual Value 3

M. Gogolla object of the Attribute. The class Link has an operation applyrelend with an ErState and a Relend parameter returning the actual Instance of the Relend. The classes Entity and RelSchema possess an operation key returning the set of its key attributes. Apart from the shown multiplicities in the class diagram, all parts must be restricted by appropriate constraints. In the total we obtain about 50 constraints. But we show only one typical example from each of the four parts. Syntax of the ER data model: Within one Entity, different Attributes have different names. context self:entity inv uniqueattributenameswithinentity: self.attribute->forall(a,a2 a.name=a2.name implies a=a2) Semantics of the ER data model: Two different Instances of one Entity can be distinguished in every ErState (where both Instances occur) by a key Attribute of the Entity. context self:instance inv keymapunique: Instance.allInstances->forAll(self2 self<>self2 and self.entity=self2.entity implies self.erstate->intersection(self2.erstate)->forall(s self.entity.key()->exists(ka self.applyattr(s,ka)<>self2.applyattr(s,ka)))) Syntax of the Relational data model: The set of key Attributes of a Rel- Schema is not empty. context self:relschema inv relschemakeynotempty: self.key()->notempty Semantics of the Relational data model: The Attributes connected to the RelSchema of a Tuple are identical to the Attributes connected to the Attr- Map of the Tuple. In other words, there are Attribute assignments for all Attributes of a Tuple. context self:tuple inv commutativityattribute: self.relschema.attribute=self.attrmap.attribute->asset The modeling is probably best explained by an example. Figure 2 shows an example scenario which is represented in Fig. 3 as an ER schema, in Fig. 4 as an ER state, in Fig. 5 as a Relational schema, and in Fig. 6 as a Relational state. These object diagrams are however not complete with respect to the links between syntax and semantics. For example, every object in Fig. 4 is typed by a link (belonging to one of the bent associations in Fig. ) to an object in Fig. 3. Thus, e.g., the five Value objects in the bottom of Fig. 4 possess typing links to the two DataType objects in the bottom of Fig. 3. In order to make the presentation comprehensible we have ommitted these details. 4

Metamodeling Syntax and Semantics passport:integer wife Person Marriage date:string gender:string husband diana wife Marriage husband charles 23 female 98/07/29 456 male Person(passport:Integer,gender:String) Marriage( wife_passport :Integer, husband_passport :Integer,date:String) Person passport gender --------+----------+---------- 23 female 456 male Marriage wife_passport husband_passport date ----------+---------------+------------------+-------------- 23 456 98/07/29 Fig. 2. Content of Example Scenario Fig. 3. Example Scenario as an ER Schema 5

M. Gogolla Fig. 4. Example Scenario as an ER State Fig. 5. Example Scenario as a Relational Schema 6

Metamodeling Syntax and Semantics Fig. 6. Example Scenario as a Relational State 3 Metamodeling Transformations Let us now turn to the transformation between the languages. We will model the transformation by a special class Trans which has associations to the respective syntax and semantics classes already introduced and which has constraints attached to it which guarantee desired properties. ErSchema ErState 0.. 0.. 0.. Trans 0.. 0.. RelDBSchema 0.. RelDBState Fig. 7. Transformation Class and Associations The class diagram in Fig. 7 shows the class Trans needed for the transformation and the respective associations. A Transformation object is associated with ex- 7

M. Gogolla actly one ER schema and exactly one Relational database schema. It additionally can be connected to ER and Relational states which in turn can be connected through an association expressing that both states are equivalent. As for the syntax and semantics of the data models the Transformation class diagram must be restricted by another 0 constraints in order to allow only meaningful situations. We here discuss only two example constraints, one dealing with schema aspects and the other one dealing with state aspects. 3. Schema aspect For every Entity in the ErSchema there is a RelSchema having the same name and Attributes with the same properties, i.e. name, DataType, and key property. context self:trans inv relschemaforentity: self.erschema.entity->forall(e self.reldbschema.relschema->select(rl -- existsone e.name=rl.name and e.attribute->forall(ea rl.attribute->select(ra -- existsone ea.name=ra.name and ea.datatype=ra.datatype and ea.iskey=ra.iskey)->size=))->size=) 3.2 State aspect For every Tuple in the RelDBState () there is either exactly one Instance such that for every AttrMap of the Tuple there is exactly one AttrMap in the Instance holding the same information or (2) there is exactly one link such that for every AttrMap of Tuple the following holds: (A) if the AttrMap belongs not to a key Attribute, there is exactly one AttrMap in the Link holding the same information, and (B) if the AttrMap belongs to a key Attribute, there is exactly one RelendMap in the Link and exactly one AttrMap of the RelendMap such that the AttrMap from the Tuple and the AttrMap from the Link hold the same information. context self:er2rel_trans inv tuplecorrespondstoinstancexorlink: self.reldbstate.tuple->forall(t self.erstate.instance->select(i -- existsone t.attrmap->forall(amrel i.attrmap->select(amer -- existsone amer.attribute.name=amrel.attribute.name and amer.value=amrel.value)->size=))->size= xor 8

Metamodeling Syntax and Semantics self.erstate.link->select(l -- existsone t.attrmap->forall(amrel ( not(amrel.attribute.iskey) implies l.attrmap->select(amer -- existsone amer.attribute.name=amrel.attribute.name and amer.value=amrel.value)->size= ) and ( amrel.attribute.iskey implies l.relendmap->select(rm -- existsone rm.instance.attrmap->select(amer amer.attribute.iskey)-> select(amer -- existsone amrel.attribute.name = rm.relend.name.concat( _ ).concat(amer.attribute.name) and amrel.value=amer.value)->size=)->size=)))->size=) For a notion of equivalence between an ER state and a Relational state one has to consider two directions of the translation, namely first the direction from ER to Relational and second the direction from Relational to ER. The above constraint touches the second direction from Relational to ER (for each tuple there is an instance or a link). The first direction is also covered by the constraints but not shown here (for each instance and link there is a tuple). Both directions together establish a correctness criterion, namely the equivalence between the ER state space and the Relational state space. As far as we know, such a correctness criterion, i.e., the equivalence between the respective state spaces, is always the aim of translating data models but such a criterion has not been stated explicitly and completely formally in the literature up to now. We emphasize that our approach allows to discuss these questions only because we have rigorously described the data models and their transformation within a single framework, namely with the language of UML class diagrams and OCL constraints. However, the approach is not bound to UML and OCL. 4 Relationship to Language Engineering We think that the underlying principal ideas lying behind the concrete translation and the concrete languages which we consider, i.e., the ER and Relational data models and their translation, can be used in other domains like classical compilers or modern approaches like model-driven development as well. We classify the central ingredients of our approach as follows: (A) Formally describe the syntax and the semantics of your language (or perhaps more generally of your domain). Explicitly distinguish between syntactical and semantical aspects and explicitly establish the connection between syntax and semantics. 9

M. Gogolla (B) If you need a second language (or domain) also describe this formally as you have done with the first language (or domain). The second language may of course be derived from your first language (or domain) by specialisation, e.g., by adding more constraints. (C) Explicitly describe the translation by introducing concepts for the translation and by restricting it through appropriate constraints. Such restrictions can describe correctness criteria for the translation. Insist on using the same description mechanism for all three ingredients, i.e., the source language, the target language, and the translation. Using one single description mechanism enables you to check and to reason about your language engineering system homogeneously. (D) Test, test, test. References [GL03] Martin Gogolla and Arne Lindow. Transforming Data Models with UML. In Borys Omelayenko and Michel Klein, editors, Knowledge Transformation for the Semantic Web, pages 8 33. IOS Press, Amsterdam, 2003. [GLRZ02] Martin Gogolla, Arne Lindow, Mark Richters, and Paul Ziemann. Metamodel Transformation of Data Models. In Jean Bezivin and Robert France, editors, Proc. UML 2002 Workshop in Software Model Engineering (WiSME 2002). Technical Report, University of Nantes, http://www.metamodel.com/wisme-2002, 2002. [Gog94] Martin Gogolla. An Extended Entity-Relationship Model - Fundamentals and Pragmatics. Springer, Berlin, LNCS 767, 994. [Gog95] Martin Gogolla. Towards Schema Queries for Semantic Data Models. In Norman Revell and A Min Tjoa, editors, Proc. 6th Int. Conf. and Workshop on Database and Expert Systems Applications (DEXA 95), pages 274 283. ONMIPRESS, San Mateo, 995. [LGR0] Arne Lindow, Martin Gogolla, and Mark Richters. Ein formal validiertes Metamodell für die Transformation von Schemata in Informationssystemen. In K. Bauknecht, W. Brauer, and T. Mück, editors, Proc. GI Jahrestagung (GI 200), Band, Workshop Integrating Diagrammatic and Formal Specification Techniques, pages 662 669. Austrian Computer Society, Wien, 200. 0