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!

How to use referencial intergrity with compound primary key 1

Status
Not open for further replies.

Clipper4000

Programmer
Dec 13, 2004
5
US
Hi,

This question has came up once on July 2004, but no conclusive answers were given.

How would I set referencial intergrity in the relationship window if my tables use 2 fields combined as a compound primary key. (ie, PurchaseNumber & ItemNumber).

I know how to set the relationship, but I am having trouble forcing the referencial intergrity. Reason is PurchaseNumber & ItemNumber is unique; however, take separately they are not unique.

Thank you for any suggestion in advance.
 
Congratulations on solving your own problem; you get a star. Now, can you teach my users how to solve their own problems, please?

-------------------------
The trouble with doing something right the first time is that noboby appreciates how difficult it was.
- Steven Wright
 

Hi,

To create a compound primary key:

1). Go to table design.
2). Select the Index icon.
3). Define a list of field names (in the field name column) to be included in the compound primary key in the order you like. This list of field names will then act as one primary key name.
4). Now you need a name for this primary key. In the index name column, put whatever name you like in the first row only and leave other rows blank.

To fullfill referencial intergrity, make sure you include all the fields names in the compound primary key, and that all the correspondent field names exist in the related table. Of course, the related table's compound primary key will have to be setup the same way.

Hope this help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top