I have 2 tables, eg. EarningDescriptions and EmployeeDetails with 1 column in each to simplify the question. EarningsLineNo in EarningsDescriptions and EmployeeCode in EmployeeDetails.
i created another table that references 2 columns in that table to the 2 columns in the other 2 tables as such :
-
-
Create table Earnings
-
(
-
EarningLineNo int references EarningDescriptions(EarningLineNo) not null,
-
EmployeeCode nvarchar(50) references EmployeeDetails(EmployeeCode) not null,
-
EarningAmount decimal not null,
-
Primary key (EarningLineNo, EmployeeCode)
-
)
-
I used a composite key because the EarningLineNo and EmployeeCode in the new table will be used over and over again. but the same combination wld not be for instance. 1-1. 2-3 etc
I would like to knw what the referencing to the other columns is actually for and if its necessary or not ?
Is it for saving purposes or maybe making sure information is similar in the columns in both tables....