I had a similar question for support a few weeks ago. If you right-click on the Attribute in the class diagram, select Properties, then you will see a property/attribute called IsID under the Advanced header. So I thought that the transform process should use that, instead of creating a standard <ClassName>ID column for the Primary key. EA support people disagreed, and thought it was fine for EA to ignore IsID. I'm not sure what the point is of having the IsID property/attribute....
So you will need to alter the Transform Templates yourself, for the DDL language. You will need to alter:
- Attribute: add code to suppress creating the column in this template, if the attribute is to be used as the PK
- Class: add code to skip the standard Transform Template code to create the standard PK column (<ClassName>ID) and to instead create a PK based on your requirements
- Connection: If the PK column has changed, you also need to alter all the Transform Template code in this template that creates a column for the FK column in a table that refers to the table for which you altered the PK column, plus alter the creation of the FK constraint.
I did the above, but I only altered Connection as far as was necessary for my case. For example, I only wanted to alter the PK for tables that would be used as lookup/reference/type tables; e.g. a Status table, and then other tables would have a "StatusCode" column and an FK to Status.StatusCode.
Relationships such as many-to-many, or inherited classes (Generalization) are not yet handled.
I wrote the Transform Template alterations so that you must add up to two Tagged Values on the class:
- one to specify the column to be used as the PK
- one to specify the data type for the column to be used as the PK (Yes it would have been smarter to somehow find the required Attribute and read the datatype value, but I did not quickly see a way to do this in the documentation that EA provides. If you find a better way, please let me know.
Will the above be sufficient for you? I can paste in the code if it is. I will ask in another post where this type of code should be posted, to help the community.
Dale Fox