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 -> Part of Primary Key or New Constraint

Part of Primary Key or New Constraint

From: mike <hillmw_at_charter.net>
Date: 16 Mar 2005 12:39:12 -0800
Message-ID: <1111005552.276908.76790@g14g2000cwa.googlegroups.com>


I have the li_struct defined like:

ALTER TABLE LI_STRUCT
ADD CONSTRAINT XFK_LI_STRUCT_PARENT FOREIGN KEY (PAR_STRUCT_ID)

                        REFERENCES LI_STRUCT_DEF(STRUCT_DEF_ID)

ALTER TABLE LI_STRUCT
ADD CONSTRAINT XFK_LI_STRUCT_CHILD FOREIGN KEY (CHD_STRUCT_ID)

                        REFERENCES LI_STRUCT_DEF(STRUCT_DEF_ID)

ALTER TABLE LI_STRUCT
            ADD CONSTRAINT XPK_STRUCT_IDX PRIMARY KEY (STRUCT_ID)

CREATE TABLE LI_STRUCT
(

STRUCT_ID       INTEGER          NOT NULL,
PAR_STRUCT_ID          INTEGER   NOT NULL,
CHD_STRUCT_ID          INTEGER   NOT NULL,
STRUCT_LEVEL           INTEGER NOT NULL,
STATUS                 CHAR(15) NOT NULL
)

This says my struct_id is my primary key. It is assigned by a sequence.

PAR_STRUCT_ID and CHD_STRUCT_ID both need to be defined in the table LI_STRUCT_DEF. Question I have is I need PAR_STRUCT_ID and CHD_STRUCT_ID both uniquely defined as well, so I need a constraint.

Do I make them part of the primary key?

Mike Received on Wed Mar 16 2005 - 14:39:12 CST

Original text of this message

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