Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Part of Primary Key or New Constraint
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