Book a Demo

Author Topic: Model transformation to DDL: multiplicity & NULL  (Read 3519 times)

Peter Parslow

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Model transformation to DDL: multiplicity & NULL
« on: January 26, 2010, 10:46:04 pm »
Hi,
In a UML class, I can set the multiplicity lowe bound to 0, which means to me that the attribute is optional, or 1 (or more), which would mean it is mandatory.

When I transform the package to DDL, the attributes come through stereotyped as columns, but all of them have Not null set to No. The only columns which get not null set to Yes are the primary keys which the transform creates.

Conversely, where a column is introduced to carry the foreign key for an association, it is often given Not Null = Yes, even if the association has a multiplicity lower bound of 0.

It's the "often" that has got me worried - in a given model, some of these optional associations get foreign key columns that can be null, others can't be.

Any thoughts as to why this is?

dannodj

  • EA Novice
  • *
  • Posts: 18
  • Karma: +0/-0
    • View Profile
Re: Model transformation to DDL: multiplicity & NU
« Reply #1 on: January 27, 2010, 03:27:53 am »
Peter,
The transform template for the DDL attributes is :
Column
{
  %TRANSFORM_CURRENT("type", "stereotype", "collection", "constant", "containment", "ordered", "static", "volatile")%
  type=%qt%%CONVERT_TYPE(genOptDefaultDatabase,attType)%%qt%
}

I'm no expert in DDL, but there doesn't appear to be any specific manipulation of the attLowerBound or attUpperBound properties, whereas in the XSD transform it contains these lines:

%if attLowerBound!=""%
  Tag
  {
    name="minOccurs"
    value=%qt%%attLowerBound=="*" ? "unbounded" : value%%qt%
  }
%endIf%
%if attUpperBound!=""%
  Tag
  {
    name="maxOccurs"
    value=%qt%%attUpperBound=="*" ? "unbounded" : value%%qt%
  }
%endIf%

It may be that you need to change the default code to do something explicitly as above.
Hope this helps.
Dan

Peter Parslow

  • EA Novice
  • *
  • Posts: 11
  • Karma: +0/-0
    • View Profile
Re: Model transformation to DDL: multiplicity & NU
« Reply #2 on: May 12, 2011, 01:10:07 am »
I can just about read the XSD one, but the DDL one relies on the TRANSFORM_CURRENT built in function.

Would I need to replicate whatever that does, or can I just tack something to handle attLowerBound on the end, setting "NOT NULL" at the end of the string. Guess I'll have to make time to try it!