Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: naming conventions for constraints

Re: naming conventions for constraints

From: andrewst <member14183_at_dbforums.com>
Date: Wed, 30 Apr 2003 12:48:25 +0000
Message-ID: <2824311.1051706905@dbforums.com>

Originally posted by SöNke Petersen
> Hello,
>
> after studying some documents on naming conventions the main
> recommendations
> for constraints seem to be that constraints should be named as the
> table it
> is applied to, followed by a suffix which identifies its type.
>
> table name: systems
>
> possible constraint names could be:
>
> systems_pk --> primary key constraint
> systems_fk --> first foreign key constraint
> systems_fk2 --> second foreign key constraint
>
> A second approach could be to apply the column name as well:
>
> systems_id_pk --> primary key constraint
> systems_hostname_fk --> foreign key constraint
>
> What are your opinions?
>
> Sönke

The main thing is to be consistent. Most databases I have worked on have a standard abbreviation for each table name, e.g. "EMP" for EMPLOYEES, "WBS" for WORK_BREAKDOWN_STRUCTURES, etc. These abbreviations are then used in constraint names like this:

EMP_PK -- primary key on EMPLOYEES
WBS_EMP_FK -- foreign key from WBS to EMPLOYEES
EMP_NAME_UK -- unique key on EMPLOYEE(surname,forename)
EMP_DOB_CHK -- check constraint on EMPLOYEES.DATE_OF_BIRTH

--
Posted via http://dbforums.com
Received on Wed Apr 30 2003 - 07:48:25 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US