Chapter 3 DBMS Reference Guide


Constraint name template

DBMS uses variables and variable formatting to define constraint name templates. These are defined by the value of the DBMS field ConstName. There are ConstName fields for the following object categories:

Category Description
TABLE Constraint name template for table checks
COLUMN Constraint name template for column checks
PKEY Constraint name template for primary keys
KEY Constraint name template for alternate keys
REFERENCE Constraint name template for foreign keys

In PowerDesigner, you can define user-defined constraint names. Templates apply to all constraints for which you do not define user-defined constraint names.

Code and Generated code variables

Many objects have Code and Generated Code variables which are differentiated as follows:

Variable Description
Code Attribute code defined in the property sheet
Generated Code Code computed according to generation options. The generated code can be different from the code in the following cases:

Code is a reserved word or contains invalid characters. The generated code is quoted

Code is longer than the length authorized by the DBMS. The generated code is truncated

For a list of all the variables used in PowerDesigner, see section "PDM variables".

Common naming variables for ConstName

The ConstName field for all objects can accept the following common variables:

Variable Description
%@OBJTNAME% Object name
%@OBJTCODE% Object code
%@OBJTLABL% Comment for the object
%@OBJTDESC% Description for the object

TABLE ConstName

The ConstName field for the object TABLE can accept the following variables:

Variable Value
%TABLE% Generated code of the table
%TNAME% Table name
%TCODE% Table code
%TLABL% Table comment

COLUMN ConstName

The ConstName field for the object COLUMN can accept the following variables:

Variable Value
%COLUMN% Generated column code
%COLNAME% Column name
%COLNCODE% Column code

PKEY ConstName

The ConstName field for the object PKEY can accept the following variable:

Variable Value
%CONSTNAME% Constraint name

KEY ConstName

The ConstName field for the object KEY can accept the following variables:

Variable Value
%AKEY% Code of the alternate key
%TABLE% Code of the table

REFERENCE ConstName

The ConstName field for the object REFERENCE can accept the following variables:

Variable Value
%REFR% Generated code of the reference
%PARENT% Generated code of the parent table
%PNAME% Parent table name
%PCODE% Parent table code
%CHILD% Generated code of the child table
%CNAME% Child table name
%CCODE% Child table code
%PQUALIFIER% Parent table qualifier
%CQUALIFIER% Child table qualifier
%REFRNAME% Reference name
%REFRCODE% Reference code
%PKCONSTRAINT% Parent key constraint name used to reference the object
%POWNER% Parent table owner
%COWNER% Child table owner
%CHCKONCMMT% TRUE when check on commit is selected on the reference (ASA 6.0 specific)

Example

The following example shows the use of constraint name templates for Sybase Adaptive Server Anywhere 6.

The DBMS Adaptive Server Anywhere 6 contains the following values for the field ConstName:

Category Comment Value
PKEY Constraint name template for Primary Keys PK_%.U27:TABLE%
REFR Constraint name template for Foreign Keys FK_%.U8:CHILD%_%.U9:REFR%_%.U8:PARENT%
KEY Constraint name template for Alternate Keys AK_%.U18:AKEY%_%.U8:TABLE%
COLN Constraint name template for Check of Column CKC_%.U17:COLUMN%_%.U8:TABLE%
TABL Constraint name template for Check of Table CKT_%.U26:TABLE%

The resulting script that you could generate for a table using Adaptive Server Anywhere 6 declares constraint names as follows:

create table DISCOUNT
(
    DISCOUNT_ID      T_IDENTIFIER           not null,
    STOR_ID          T_AN_IDENTIFIER        not null,
    DISC_PERCENT     T_PERCENT              not null,
    DISC_TYPE        T_SHORT_TEXT           null    
        constraint CKC_DISC_TYPE_DISCOUNT check (DISC_TYPE in ('High','Medium','Low')),
    DISC_LOWQTY      T_QUANTITY             null    ,
    DISC_HIGHQTY     T_QUANTITY             null    ,
    constraint PK_DISCOUNT primary key (DISCOUNT_ID)
)
go

 


Copyright (C) 2005. Sybase Inc. All rights reserved.