Book a Demo

Author Topic: DB model. Generating DB Schema  (Read 4906 times)

MiloszeS

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
DB model. Generating DB Schema
« on: December 16, 2009, 03:23:05 am »
Hi all,

I've modelled a DB using EA 7.5. A db contains a four schemas (I've added a schema stereotype on a package containing tables). During a DDL generation everything works fine except schemas. All tables has been generated under a public schema. What should i switch to generate tables in a designed schemas.

As a db I've chosen a posgtresql.


Regards,
MiloszeS
« Last Edit: December 16, 2009, 10:03:59 pm by miloszes »

Oliver F.

  • EA User
  • **
  • Posts: 573
  • Karma: +2/-1
  • Aren´t we all in the model business ?
    • View Profile
    • Karl Storz homepage
Re: DB model. Generating DB Schema
« Reply #1 on: December 16, 2009, 03:34:38 am »
This is one of the reasons why we went away from the DDL script generation.
Now, we use a custom template to create the appropriate SQL scripts. The schema is written in a tagged value during transformation and the filename of the file to create is set appropriately (eg. schema1.sql, etc.).
That way you can set the appropriate usage statement for the schema.

Oliver

MiloszeS

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: DB model. Generating DB Schema
« Reply #2 on: December 16, 2009, 06:03:03 pm »
Should I use a code generation templates or transformation templates? Sorry for a silly question, but I'm a rookie in a template area.


MiloszeS
« Last Edit: December 16, 2009, 06:03:18 pm by miloszes »

Oliver F.

  • EA User
  • **
  • Posts: 573
  • Karma: +2/-1
  • Aren´t we all in the model business ?
    • View Profile
    • Karl Storz homepage
Re: DB model. Generating DB Schema
« Reply #3 on: December 16, 2009, 06:42:46 pm »
Quote
Should I use a code generation templates or transformation templates? Sorry for a silly question, but I'm a rookie in a template area.

Sorry about not being precise enough. I am refering to SQL code generation. The integrated DDL code generation can not handle multiple DB schema definitions as far as I have noticed. Therefore we transform the model with the schema being written into tagged values and then generate SQL code through our own custom language code templates which in fact simply creates the SQL scripts.

Oliver

MiloszeS

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: DB model. Generating DB Schema
« Reply #4 on: December 16, 2009, 07:02:52 pm »
Thank you.

Regards,
MiloszeS

MiloszeS

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: DB model. Generating DB Schema
« Reply #5 on: December 16, 2009, 10:06:35 pm »
OK,

I've created my own template. A schema, table names, fields and comments are ok. Unfortunately I cannot find a way to retrieve an info about PK and FK.

I've founded a PK name but, cannot find info about which field is described by the operation. Could you help me with that?


Regards,
MiloszeS

Oliver F.

  • EA User
  • **
  • Posts: 573
  • Karma: +2/-1
  • Aren´t we all in the model business ?
    • View Profile
    • Karl Storz homepage
Re: DB model. Generating DB Schema
« Reply #6 on: December 17, 2009, 02:08:20 am »
Quote
OK,

I've created my own template. A schema, table names, fields and comments are ok. Unfortunately I cannot find a way to retrieve an info about PK and FK.

I've founded a PK name but, cannot find info about which field is described by the operation. Could you help me with that?

Primary keys are operations with the PK stereotype and the field used as parameter so you can create an operation template and override it by a template triggered by that stereotype. For PK and Oracle this looks like this:
Code: [Select]
ADD CONSTRAINT %opName% UNIQUE ( %list="Parameter" @separator="," @indent=""% )

For a PK a constraint is added with all parameters (usually only 1) in the brackets.
For other databases it might look different but you get the idea, hopefully.

Oliver

MiloszeS

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
Re: DB model. Generating DB Schema
« Reply #7 on: December 17, 2009, 06:20:13 pm »
%list="Parameter" @separator="," @indent=""% - this is a reason, why it doesn't worked in my case. I've used it as a 1:1 relation (%Parameter%).

Thanks again.
MiloszeS