Book a Demo

Author Topic: How to set default Owner for tables for Transformations from domain model  (Read 4498 times)

ea0818

  • EA Novice
  • *
  • Posts: 8
  • Karma: +1/-0
    • View Profile
I have a Business Domain Model, that has the classes, with their attributes and relationships.

I can use Ribbon - Design - Tools - Transform - Apply Transformation.  This creates or synchronizes database tables in a Database model in the EA project.

I need to make some changes to how EA transforms the classes to the database tables.  I have been able to make several changes in the Transformation scripts for the DDL language, but there are a couple things I do not see how to accomplish.

1)  How do I set a default value for the Owner value in created database tables?  E.g., in the properties for the database table, choose Table Detail tab, and see the Owner field.  I want the default Owner for all tables to be "dbo".

2)  How do I change the Transform template scripts so that, in the generated database table, the PK column will be first, followed by any FK columns, lastly followed by the columns created from the attributes of the source class?  I tried editing the Class script to move the Primary Key code before the line with %list="Attribute" @separator="\n" @indent="  "%, but it had no effect.

Is there somewhere that I can find documentation for all destination-class tags that are supported by EA?  For example, I should be able to find documentation for whatever code I need to include in my Transformation DDL script to set the Owner tag for the destination database table.

Thanks.

ea0818

  • EA Novice
  • *
  • Posts: 8
  • Karma: +1/-0
    • View Profile
Re: How to set default Owner for tables for Transformations from domain model
« Reply #1 on: September 21, 2020, 01:37:58 pm »
And a couple questions about cross-reference tables. 
In my Domain Model I have a relationship between two classes; I'll use the example of Student and Course.  The relationship between these classes has multiplicity of 0..* on both sides. 
When doing the transform to DDL, EA therefore needs to create a cross-reference database table, StudentCourse.  StudentCourse lives between the two database tables of Student and Course.  EA correctly adds two columns to StudentCourse; these are used to provide the Foreign Key from that cross reference table to the Primary Key ID column in the two other tables; i.e. column StudentID is used for the FK to Student and CourseID is used for the FK to Course.

Problem 1:  EA is creating the two columns in the StudentCourse cross-reference table with "not null" set to false; but "not null" should be true for both columns in the StudentCourse cross-reference table.  You will only create a record in this cross-reference table when you are linking a Student to a Course, so both columns should be mandatory.  See settings for connection between the domain classes below.

Problem 2:  EA is not adding a Primary Key to this StudentCourse cross-reference database table.  The PK should be the two columns.  See settings for connection between the domain classes below.


I think I have correctly modeled the classes and their relationship in the Domain model; in the Association Properties dialog for the relationship, in the Role(s) section, I have the following values for both sides of the relationship:
Multiplicity:  0..*
Ordered:  False
Allow Duplicates:  False  (if this was true, then I would understand Problem 2 above)
Stereotype:  (blank)
Alias:  (blank)
Access:  Public
Navigability:  Unspecified
Aggregation:  none
Scope:  instance
Constraints:  (blank)
Qualifiers:  (blank)
Member Type:  (blank)
Changeable:  none
Containment:  Unspecified
Derived:  False
Derived Union:  False
Owned:  False

Thank you for any assistance.

horszasz

  • EA User
  • **
  • Posts: 22
  • Karma: +6/-0
  • My name is Gergely :)
    • View Profile
Re: How to set default Owner for tables for Transformations from domain model
« Reply #2 on: September 23, 2020, 07:26:07 pm »
Problem 1:  EA is creating the two columns in the StudentCourse cross-reference table with "not null" set to false; but "not null" should be true for both columns in the StudentCourse cross-reference table.  You will only create a record in this cross-reference table when you are linking a Student to a Course, so both columns should be mandatory.  See settings for connection between the domain classes below.
I think, this is just a small inconsistency in the default transformation templates of EA. In my opinion the default transformation templates of EA aren't some kind of ultimate solution, these are just good starting point for creating your own customized  templates. This is true for DDL transformation, and also for other transformation types (XSD, WSDL, etc). So, if you want have more accurancy, you have to modify the templates...


Problem
Problem 2:  EA is not adding a Primary Key to this StudentCourse cross-reference database table.  The PK should be the two columns.  See settings for connection between the domain classes below.
(...)
Allow Duplicates:  False  (if this was true, then I would understand Problem 2 above)

See my previous paragraph. I don't think EA's default DDL transformation is using this attribute ("allow duplicates") for anything.

Regards,
Gergely

« Last Edit: September 23, 2020, 07:28:04 pm by horszasz »

horszasz

  • EA User
  • **
  • Posts: 22
  • Karma: +6/-0
  • My name is Gergely :)
    • View Profile
Re: How to set default Owner for tables for Transformations from domain model
« Reply #3 on: September 23, 2020, 07:43:45 pm »
1)  How do I set a default value for the Owner value in created database tables?  E.g., in the properties for the database table, choose Table Detail tab, and see the Owner field.  I want the default Owner for all tables to be "dbo".

Try to set the values of  the tags "Owner" and "Tablespace" of the generated table object. You can do it manually in the generated model, or by modifying the transformation template.


2)  How do I change the Transform template scripts so that, in the generated database table, the PK column will be first, followed by any FK columns, lastly followed by the columns created from the attributes of the source class?  I tried editing the Class script to move the Primary Key code before the line with %list="Attribute" @separator="\n" @indent="  "%, but it had no effect.
The order of how the transformation script generates the single columns of a table into the target model, you are not able to control, I think.
Maybe it is possible to control how the code generator generates DDL file from the DDL model. In XSD model it is possible to set "position" tag for every field of an XSD class, and the generator takes it into consideration during generating XSD file. But I am not sure if it works with DDL scripts too.

G.