If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > FK PK relations

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-14-03, 08:45
Bhushan_sawant Bhushan_sawant is offline
Registered User
 
Join Date: Nov 2003
Posts: 7
FK PK relations

Hi All,

I have one query...
I have composite primary key on two columns ....say on table XYZ...

can i have one of this column as foreign key column for which values should be validated from other tables column...

Can i define the column as FK which is already defined in another composite PK.

How i should do this.....


Thanks in advance

Bhushan Sawant
Reply With Quote
  #2 (permalink)  
Old 11-17-03, 07:35
Roelwe Roelwe is offline
Registered User
 
Join Date: Aug 2002
Location: Belgium
Posts: 534
example:

CREATE TABLE xyz (col1 SERIAL, col2 INT);

CREATE UNIQUE INDEX xyz_pk ON xyz(col1,col2);

ALTER TABLE xyz ADD CONSTRAINT (PRIMARY KEY (col1,col2) CONSTRAINT xyz_pk);

ALTER TABLE xyz ADD CONSTRAINT (FOREIGN KEY (col2) REFERENCES other_table CONSTRAINT xyz_fk1);


The value of the foreign key must (in this case) exist in the primary key constraint of table other_table.
__________________
rws
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On