0

Sybase Powerdesigner - 如何自动格式化PK和FK的命名?

运行脚本以像这种格式一样格式化主键和外键

PK_TABLENAME

FK_PARENT_CHILD

例子

PK_Post

FK_Post_Comment
4

2 回答 2

0

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: 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.

enter image description here

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.

enter image description here

于 2013-09-20T10:46:41.120 回答
0

至少对于外键,您可以创建一个 Initialize 事件处理程序来定义附加表中的名称。当您在图表中创建参考时,它将起作用;当您通过列表创建它时可能不是(因为尚未附加表格)。

在此处输入图像描述

我离开作为处理名称冲突的练习......

对于主键,您可以在 Key 元类上使用 Validate 事件处理程序,并在它成为主键时重命名该键(除非它的名称已经以“PK”开头)。

于 2013-10-09T10:11:32.883 回答