Book a Demo

Author Topic: DDL generation primary keys, and indexes.  (Read 4290 times)

TonyN

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
DDL generation primary keys, and indexes.
« on: May 10, 2012, 03:16:08 pm »
HI All,

I am trying to get the DDL generaton tool to create (from a logical model), a multi column primary key and I also need to designate another column as having unique content and nulls not allowed.

Could somebody please advise what needs to be specified in the logical model class to have this occure in the table object that is generated by the DDL transform.

Also is there a way to go from DDL back to logical model (ie. round trip)?

Regards,
Tony

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: DDL generation primary keys, and indexes.
« Reply #1 on: May 10, 2012, 06:56:35 pm »
I can only answer the 2nd question: there is no real round trip for DDL. But you can import a database schema so EA creates a class model. This is not in synch with a generated DDL, though.

q.

Ondrej Kolenaty

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Re: DDL generation primary keys, and indexes.
« Reply #2 on: May 29, 2012, 08:04:44 pm »
For multicolum PK you have to put into class transformation template a PrimaryKey {} section with one or more Column {} in it. For example create a new attribute template named Attribute__Primary_Key with such content:

$isPk=%FIND(%attStereotype%, "PK")%  
%if $isPk != "-1"%
Column
{
 %if attAlias != ""%
    name=%qt%%attAlias%%qt%
  %else%
    name=%qt%%EXEC_ADD_IN("CS_AdisAddin", "getClassAlias", attClassifierGUID)%%qt%
  %endIf%
}
%endIf%

and in class templete use it:

PrimaryKey
    {
      name=%qt%pk%classAlias%%qt%
      %list="Attribute__Primary_Key" @separator="\n" @indent="  "%
    }