cancel
Showing results for 
Search instead for 
Did you mean: 

Naming rules for a FK relationship

former_member1194361
Participant
0 Kudos

Where can I look for the rules that PD uses in generating these 3 things for an FK relationship.

Name

Code

Constraint Name

Right now, when I add a relationship between two tables in PD(16.1), it generates the Name and Code as "Reference_NNNN" and the Constraint Name as "FK_parent tablename + child table name"

I want to edit the rules so that all 3 are generated as FK_table_name_NN with NN being increased sequentially as FKs are added to that table.

Accepted Solutions (1)

Accepted Solutions (1)

former_member192453
Active Participant
0 Kudos

When creating a new object, you do not have control of the naming template. Therefore, for "Reference_NNNN", you can not create a template. There is an open enhancement request for this functionality.

For the Constraint Name, this change can be made in the DBMS file.

In your PDM, select the Database\Edit Current DBMS menu

navigate to :Script\Objects\Reference\ConstName

The following template should meet your needs:

FK_%TABLE%_%REFRNO%

Or replace %TABLE% with any of the following enclosed by % %

   "PARENT"       // generated code of the parent table

   "PNAME"        // name of the parent table

   "PCODE"        // code of the parent table

   "CHILD"        // generated code of the reference

   "CNAME"        // name of the child table

   "CCODE"        // code of the child table

Anthony

Answers (2)

Answers (2)

former_member1194361
Participant
0 Kudos

Thanks Anthony that works.

There is a little quirk, but we can live with that. Where the relationship is single digit, our standard is to generate it as FK_TableName_01, FK_TableName_02

But that will be difficult to achieve with the template, so will ask the DBAs to change the standard.

arnaud_laurent
Employee
Employee
0 Kudos

The templates are defined in the DBMS resource file (.xdb file).

In PDM, select Database > Edit Current DBMS. In the DBMS properties window, select ::Script\Objects\Reference\ConstName.

This is where you find the template for the constraint name.

During intermodel generation, you can specifiy your own FK column name template.

For exmaple, from CDM, select TOols > Generate Physical Data Model and click the Details tab.

HTH