I have an issue where I need to create a relationship between two tables, but the uniqueness is only between two fields in both of the tables. Neither one of the values is unique on their own. The database being used is currently in SQL Server 2008 R2. Here's the actual scenario:
Table B contains a JobNum
column, which is already a foreign key to Table A
. Table B
also contains a column named Shipment
. This Shipment
column is not unique on its own, but when paired with a JobNum
the composite is unique. (JobNum
AND SHIPMENT
= UNIQUE) I know that I can create a unique index of the composite. However, since I inherited this project there is already a primary key, which is simply an auto-incrementing identity. Table C
contains both JobNum
and Shipment
columns, but there is no actual relationship between the two tables.
How can Table B be linked to Table C using this composite unique value? Does this need to be done with a join table?