Sybase Powerdesigner - how to automatically format naming of PK and FK?
Run script to format primary key and foreign key like this format
PK_TABLENAME
FK_PARENT_CHILD
Example
PK_Post
FK_Post_Comment
Sybase Powerdesigner - how to automatically format naming of PK and FK?
Run script to format primary key and foreign key like this format
PK_TABLENAME
FK_PARENT_CHILD
Example
PK_Post
FK_Post_Comment
The following solution is complicated, but also very flexible/ not so intrusive. This will get you started:
In your PD model, create a new "Custom check with Autofix Option" for the Table Or Column (Or Reference) metaclass object. (Doesn't matter which you cheoose. You can iterate thru sub-objects in your vbscript code, using nested foreach loops (for each table ... /for each column ...) see below:
click on Menu Item Model / Extended Model Definitions. Click on the blue-white >=== Icon.
Give your new "Extended model definition" a name, e.g. mysql55-custom-001.
Optional: Click on Export Extended Model definition, export it as mysql55-custom-001.xem.
Click on the arrow next to the name of the new extenden model definition, to save it to the default subdir.
This is the extended model dialog:
Right-Click on "Profile", click on "Add Metaclasses..." Check Column
Right Click , Select "New...", Click/Select "Custom Check".
Now add a custom check to your model. you must define a check script (in vbscript), and an autofix script.
Click on "Help" Button, Click on "Defining the Script of a custom check". You'll find a code sample to get you started. It will look like this. But you'll need to adapt the code of course with vbscripts low-level string processing functions.
At least for a Foreign-Key, you can create an Initialize event handler to define the name from the attached tables. It will work when you create a Reference in a diagram; maybe not when you create it through a list (as the tables won't be attached yet).
I leave as an exercise dealing with the name collisions...
For a Primary Key, you could use a Validate event handler on the Key metaclass, and rename the Key when it becomes Primary (unless its name already starts with "PK").