Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

constraint on composite foreign keys

Status
Not open for further replies.

peterzh

Programmer
Mar 4, 2005
5
CA
Hi Guys,
Here is my question. I have two tables A and B:

Table A (mht_nbr, act_seq_nbr) and
Table B (mht_nbr, act_seq_nbr, src_cde)

In table B all three fields are primary keys.

I want to have a constraint on field act_seq_nbr in Table A:
any value of this field must come from the values of the field act_seq_nbr in Table B.

Thanks in advance for your help!

Peter
 
Create a foreign key from table B to Table A on act_seq_nbr.

Jim
 
Sorry for the mistake in my question. It should be the other way round.

Any value of the field act_seq_nbr in Table B should come from the value of the field act_seq_nbr in Table A.

In Table A each mht_itl_nbr can have multiple act_seq_nbr.
In Table B each mht_itl_nbr has only one act_seq_nbr, and this value must be from Table A.

Because there are three key fields in Table B so I could not use act_seq_nbr in Table B referencing the field in Table A.

Thanks for your quick reply, Jim.

Peter



 
i assume the primary key of Table A is (mht_nbr, act_seq_nbr)

so just declare the foreign key in Table B as (mht_nbr, act_seq_nbr) referencing table A

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top