Menu

#22 Referential constraint and index names

open
nobody
5
2012-11-03
2005-07-22
No

The referential constraints and indices should be named
correctly in the database builder, so e.g. firebird
constraint and index names represents the table name
and not database-generated random names.

Sample created by database builder for firebird:

CREATE TABLE CUSTOMER (
CLASS VARCHAR(32) NOT NULL,
ID VARCHAR(32) NOT NULL,
UPDATECOUNT INTEGER,
CNUM INTEGER,
DESCR VARCHAR(60),
PRIMARY KEY (CLASS,ID)
)

This creates the table CUSTOMER with e.g. constraint
INTEG_10 and index RDB$PRIMARY3 for the primary key.

It should be better to use the alter table command to
add the constraints:

CREATE TABLE CUSTOMER (
CLASS VARCHAR(32) NOT NULL,
ID VARCHAR(32) NOT NULL,
UPDATECOUNT INTEGER,
CNUM INTEGER,
DESCR VARCHAR(60)
)

ALTER TABLE CUSTOMER
ADD CONSTRAINT PK_CUSTOMER PRIMARY KEY (CLASS,ID)

This creates the table CUSTOMER with constraint
PK_CUSTOMER and index PK_CUSTOMER.

Discussion


Log in to post a comment.