From Domain to Database… A Comment Conundrum

Is it possible to mirror domain comments, from Domain Administration into attribute “Comments in RDBMS”? Would like to mirror these to the ddl so they can be then available in column comments in the database.

I knew that one of the example transformation scripts provided with Data Modeler copies the column “Comments” property to “Comments in RDBMS”, so I thought I would point this out to the questioner, and that would be that.

However, it seems that the “Comments” property of a domain…

is not transferred to the “Comments” property of the column defined using the domain (or the “Comments in RDBMS” property either).

Because the task at hand is so similar to the purpose of an existing script, I copied the “Copy Comments to Comments in RDBMS” script to as a new script and gave it a descriptive name. I also set the target to be a relational model, and because this script was for the forum, I set the language to Oracle Nashorn (instead of the superior Groovy Scripting Engine that I use). The existing script does a lot more than we need; it copies table, column and key comments to RDBMS Comments, so I deleted of the code to handle the comments for the tables and keys.

I was left with what is seen below; which if run, would copy the “Comments” property to the empty “Comments in RDBMS” property. But we want to copy the “Comments” property from the domain to the column.

It should be noted that if you do not assign a domain to a column, the “Unknown” domain is assigned. So, the first thing I added to the script was to check each column, to to see if the domain was not set to “Unknown”.

For those columns with a defined domain, I set a variable containing the domain comment property, and make sure that the comment is not empty.

I then follow the original script and make sure that the comment is not too long, and then set the value of the column “Comments in RDBMS” property. Setting the column as dirty essential tells the script processor that you want to “commit” this change.

And that’s it. The entire script is seen below. Apply this script to you relational model and the comments are where you want them. That being said, always save your model before applying any transformation script. It’s as close to “rollback” as you are going to get.