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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Primary key on mulitple fields question 1

Status
Not open for further replies.

bigjohn3k

Programmer
Oct 4, 2001
4
US
I have 2 tables which I want to establish a one-to-many relationship. My questions is on how to best setting the primary key:

Table A consists of 3 fields (a, b, c) which are combined as a primary key to make each record unique. Therefore I would set all these 3 fields with index-duplicate OK and also grouped them together as the primary key.

Table B consists of 3 fields (x, y) and an ID2 field as primary key.

1. I could add fields (a, b, c) to Table B as foreign key and link them together this way, but it seems like the keys would be large and inefficient since these 3 fields are defined as TEXT type.

or

2. I could add an stand-alone ID field as autonum index field to table A, which would be external to the primary key, and add this ID to Table B as foreign key for the linkage. Since I read somewhere that the linkage key in Table A has to be defined as a primary key, but I tried setting it up this way in Access and did not get any errors.

Any suggestions or clarifications would be much appreciated.
 
Your method number 2 is the correct one. You can also set referential integrity cascade update/delete for this join.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top