Author Topic: How to create Table and Column elements?  (Read 5919 times)

Marco.Farini

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
How to create Table and Column elements?
« on: March 28, 2004, 08:58:34 am »
Hi,

I know how to use to Automation Interface to create elements of any type as well as their attributes. I understand that a Table is nothing but a Class with a stereotype of <<table>> and Column is an attribute with a stereotype of <<column>>.
In the EA, when you specify a stereoytype <<table>> for a class, the properties window for the class changes and offers different options than for a regular class. Thus, one can specify DDL generation options for the table, specify that a particular column is part of primary key etc.
I can not find these attributes in the documentation for the automation interface. How can I specify that a column is part of a primary key via AI?

Thanks,
Marco

Stephen

  • EA User
  • **
  • Posts: 54
  • Karma: +0/-0
    • View Profile
Re: How to create Table and Column elements?
« Reply #1 on: March 29, 2004, 12:55:48 am »
Marco,

You're right with the table being a stereotyped element.
Columns in the table are created as attributes of the table's element.
Keys and indexes are created as methods.
The columns that participate in the index are parameters of the method.

Import a couple of tables using the GUI. Review the tables from within EA, then compare with the contents of the database - look in t_operation and t_operationparams. It should all start to make sense...

Marco.Farini

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: How to create Table and Column elements?
« Reply #2 on: March 29, 2004, 01:44:12 pm »
Excellent, thank you very much Stephen! It really does make sense once one looks into the database.
Now, is there any way how I can specify on a class (not stereotyped as table) that some of its attributes (not stereotyped as columns) have to be unique among the instances of the class? Or that it is mandatory? Is that even UML-correct? Do I have to use an attribute-level constraint to define this?

Thanks in advance!

Marco

Stephen

  • EA User
  • **
  • Posts: 54
  • Karma: +0/-0
    • View Profile
Re: How to create Table and Column elements?
« Reply #3 on: March 30, 2004, 12:38:33 am »
Marco,

You may have me there - I suspect I'm a better hacker than I am a modeller.

I would have expected that building a class structure that controls the initial state of some (key) object requires some sort of external controller. [When I hack something together I might use seeding rules in a database to control the initial state of some object].

For a generic oo style approach you might review the Abstract Factory or Builder patterns. In essence I wouldn't expect to model attribute initialisation rules to maintain primacy without reference to some external state.

Perhaps the panel can teach us both something (Or I've misunderstood your problem...)

Stephen

  • EA User
  • **
  • Posts: 54
  • Karma: +0/-0
    • View Profile
Re: How to create Table and Column elements?
« Reply #4 on: March 30, 2004, 01:01:59 am »
Marco,

Got me trawling the context menus...

There is an option to "set run state" on components.

I've no idea if this has any impact on code generation (haven't dared try to get something useful out of my models yet!)