A

Model Transformation Cod

A.1 Complete QVT Relations alma2db Example

transformation alma2db(alma : AlmaMM, db : DbMM) {
 
   /* keys are required to avoid duplication in the target
      repository on iterative runs. */
 
   /* tables are solely identified by their names. */
   key Table {name};
   /* for a column, its name as well as its container, i.e. a table,
      uniquely identify a column. */
   key Column {table, name};
   /* a key is uniquely determined by its owner, which is the table. */
   key Key {table}
   /* a foreign key is identified by its owner (the table), as well as the primary key it is
      referring to. */
   key ForeignKey{table, key}
 
   /******************************/
   /* Mapping entities to tables */
   /******************************/
 
   /* Each entity has a corresponding db table with the same name */
   top relation EntityToTable {
      prefix, eName : String;
 
   checkonly domain alma entity:Entity {
      name = eName
   };
   enforce domain db table:Table {
      name = eName
   };
   where {
      /* For each entity and associated table, we calculate
        all columns that correspond to the different fields of
        the entity. Since we flatten out all nested fields, we
        need to make sure all created columns get a unique name.
        This is achieved by the prefix. */
      prefix = “;
      RecordToColumns(entity, table, prefix);
   }
}
/* For each field of a record, several columns may be created
   depending on the type ...

Get Model-Driven Software Development: Technology, Engineering, Management now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.