-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Table mapping, composite key is foreign key too
PostPosted: Thu Jul 20, 2006 9:27 am 
Newbie

Joined: Thu Jul 20, 2006 2:45 am
Posts: 1
Location: Ukraine, Crimea, Pheodosia
I have 2 tables as follows:
Code:
CREATE TABLE PRJ_ObjNames(
  iter_id   NUMBER( 10 ) NOT NULL,
  obj_id   NUMBER( 10 ) NOT NULL,
  obj_operation   CHAR( 1 ) NOT NULL,
  type_id   NUMBER( 10 ) NOT NULL,
  obj_name   VARCHAR2( 30 ) NOT NULL,
  obj_comment   VARCHAR2( 30 ) DEFAULT ' ' NOT NULL
);
ALTER TABLE PRJ_ObjNames
  ADD CONSTRAINT PK_PRJOBJNAMES
  PRIMARY KEY( iter_id, obj_id );

CREATE TABLE PRJ_Address(
  iter_id   NUMBER( 10 ) NOT NULL,
  obj_id   NUMBER( 10 ) NOT NULL,
  adr_operation   CHAR( 1 ) NOT NULL,
  build_id   NUMBER( 10 ) DEFAULT 1 NOT NULL,
  entrance   VARCHAR2( 4 ),
  floor      VARCHAR2( 4 ),
  flat      VARCHAR2( 6 )
);
ALTER TABLE PRJ_Address
  ADD CONSTRAINT UQ_PRJADDRESS
  UNIQUE( iter_id, obj_id );
ALTER TABLE PRJ_Address
  ADD CONSTRAINT FK_PRJADDRESS_PRJOBJNAMES
  FOREIGN KEY( iter_id, obj_id ) REFERENCES PRJ_ObjNames( iter_id, obj_id )
  ON DELETE CASCADE;


The problem is to map second table because composite key is also foreign key. How can I do this mapping?
Structure of tables can't be changed. Table PRJ_Address has less rows than PRJ_ObjNames.

_________________
Don't wait, do it!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.